Submission #849373

# Submission time Handle Problem Language Result Execution time Memory
849373 2023-09-14T14:26:50 Z vjudge1 Političari (COCI20_politicari) C++17
30 / 70
368 ms 524288 KB
#include<bits/stdc++.h>
#define int long long
#define ll pair<int,int>
using namespace std;

long long a[505][505];
long long danhdau[505];
vector<int> elt;
int vt[505];
int n,k;

void dfs(int u,int v)
{
    // if (danhdau[v]>n)
    // {
    //     int l=vt[v];
    //     int r=vt[u];
    //     int leng=r-l+1;
    //     k-=l;
    //     k%=leng;
    //     cout << elt[k+l] << '\n';
    //     return;
    // }
    // else
    // {
        danhdau[v]++;
        elt.push_back(v);
        vt[v]=elt.size()-1;
        if (vt[v]==k)
        {
            cout << v;
            return;
        }
        dfs(v,a[v][u]);
    // }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    k--;
    for (int i=1;i<=n;i++)
    {
        for (int i2=1;i2<=n;i2++)
        {
            cin >> a[i][i2];
        }
    }
    elt.push_back(1);
    vt[1]=0;
    danhdau[1]++;
    dfs(1,2);
}
# Verdict Execution time Memory Grader output
1 Runtime error 288 ms 524288 KB Execution killed with signal 9
2 Runtime error 327 ms 524288 KB Execution killed with signal 9
3 Runtime error 361 ms 524288 KB Execution killed with signal 9
4 Runtime error 332 ms 524288 KB Execution killed with signal 9
5 Runtime error 365 ms 524288 KB Execution killed with signal 9
6 Runtime error 368 ms 524288 KB Execution killed with signal 9
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 1880 KB Output is correct
9 Correct 4 ms 2528 KB Output is correct
10 Correct 12 ms 4316 KB Output is correct
11 Correct 14 ms 4580 KB Output is correct
12 Correct 17 ms 6356 KB Output is correct
13 Runtime error 328 ms 524288 KB Execution killed with signal 9
14 Runtime error 325 ms 524288 KB Execution killed with signal 9