Submission #217146

#TimeUsernameProblemLanguageResultExecution timeMemory
217146VimmerPolitičari (COCI20_politicari)C++14
65 / 70
26 ms4608 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]; 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 timeMemoryGrader output
Fetching results...