| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 218149 | Vimmer | Političari (COCI20_politicari) | C++14 | 34 ms | 6528 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 200005
#define M ll(1000000007)
using namespace std;
typedef long long ll;
ll in[1000][1000], a[1001][1001];
int main()
{
    //freopen("mining.in","r",stdin); freopen("mining.out","w",stdout);
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, k;
    cin >> n >> k;
    if (k == 1) {cout << 1 << endl; exit(0);}
    for (ll i = 1; i <= n; i++)
        for (ll j = 1; j <= n; j++) cin >> a[i][j];
    k--; k--;
    ll nxt = 2, tp = 1, lst = 1;
    while (k > 0)
    {
        ll nt = nxt;
        nxt = a[nxt][lst];
        lst = nt;
        if (in[nxt][lst] != 0 && k % (tp - in[nxt][lst]) != 0)  k %= (tp - in[nxt][lst]);
        in[nxt][lst] = tp;
        tp++;
        k--;
    }
    cout << nxt << endl;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
