Submission #218149

#TimeUsernameProblemLanguageResultExecution timeMemory
218149VimmerPolitičari (COCI20_politicari)C++14
70 / 70
34 ms6528 KiB
#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 timeMemoryGrader output
Fetching results...