23242023-01-10 14:00:26bzsofiaRobotokcpp11Futási hiba 10/50456ms62600 KiB
// Robotok.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

struct adat
{
    int robi, sum;
    pair <int, int> honnan;
};

int i, n, m, db, robot, j, a, b;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m >> db;
    vector <vector<adat>> x(n+1, vector <adat> (m+1));
    
    for (i = 1; i <= db; ++i)
    {
        cin >> a >> b;
        x[a][b].robi = 1;
    }
    
    while (db>0)
    {
        ++robot;

        for (i = 1; i <= n; ++i)
        {
            for (j = 1; j <= m; ++j)
            {
                if (i == 1)
                {
                    x[i][j].sum = x[i][j - 1].sum + x[i][j].robi;
                    x[i][j].honnan = { i, j - 1 };
                }
                else if (j == 1)
                {
                    x[i][j].sum = x[i - 1][j].sum + x[i][j].robi;
                    x[i][j].honnan = { i - 1, j };
                }
                else
                {
                    if (x[i][j - 1].sum > x[i - 1][j].sum)
                    {
                        x[i][j].sum = x[i][j - 1].sum + x[i][j].robi;
                        x[i][j].honnan = { i, j - 1 };
                    }
                    else
                    {
                        x[i][j].sum = x[i - 1][j].sum + x[i][j].robi;
                        x[i][j].honnan = { i - 1, j };
                    }
                }
            }
        }

        i = n;
        j = m;
        db -= x[n][m].sum;
        while (x[i][j].honnan.first && x[i][j].honnan.second)
        {
            x[i][j].robi = 0;
            i = x[i][j].honnan.first;
            j = x[i][j].honnan.second;
        }
    }

    cout << robot;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
RészfeladatÖsszpontTesztVerdiktIdőMemória
base10/50
1Elfogadva0/03ms1828 KiB
2Futási hiba0/021ms55252 KiB
3Elfogadva2/24ms2644 KiB
4Elfogadva2/24ms2844 KiB
5Hibás válasz0/24ms3012 KiB
6Hibás válasz0/24ms2964 KiB
7Hibás válasz0/24ms3220 KiB
8Elfogadva2/221ms34388 KiB
9Elfogadva2/218ms34512 KiB
10Elfogadva2/218ms34588 KiB
11Hibás válasz0/213ms4568 KiB
12Időlimit túllépés0/2456ms18584 KiB
13Futási hiba0/228ms62600 KiB
14Futási hiba0/223ms56976 KiB
15Futási hiba0/221ms57104 KiB
16Futási hiba0/223ms60444 KiB
17Futási hiba0/426ms57364 KiB
18Futási hiba0/623ms57432 KiB
19Futási hiba0/626ms57628 KiB
20Futási hiba0/627ms57824 KiB