# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217146 | Vimmer | Političari (COCI20_politicari) | C++14 | 26 ms | 4608 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];
bool f;
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);}
ll a[n][n];
for (ll i = 0; i < n; i++)
for (ll j = 0; j < n; j++) cin >> a[i][j];
k -= 2;
ll lst = 1;
ll nxt = 2, tp = 1;
while (k > 0)
{
ll nt = nxt;
nxt = a[nxt - 1][lst - 1];
lst = nt;
if (in[nxt][lst] != 0 && !f) k %= (tp - in[nxt][lst]);
in[nxt][lst] = tp;
tp++;
k--;
}
cout << nxt << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |