Submission #209988

#TimeUsernameProblemLanguageResultExecution timeMemory
209988SamAndPolitičari (COCI20_politicari)C++17
70 / 70
38 ms2424 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair const int N = 502; int n; long long k; int a[N][N]; bool c[N][N]; int main() { scanf("%d%lld", &n, &k); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { scanf("%d", &a[i][j]); } } if (k == 1) { printf("1\n"); return 0; } k -= 2; vector<pair<int, int> > v; pair<int, int> u = m_p(2, 1); c[u.first][u.second] = true; v.push_back(u); while (k--) { pair<int, int> h = m_p(a[u.first][u.second], u.first); if (c[h.first][h.second]) { for (int i = 0; i < v.size(); ++i) { if (v[i] == h) { k %= (v.size() - i); printf("%d\n", v[i + k].first); return 0; } } } u = h; c[u.first][u.second] = true; v.push_back(u); } printf("%d\n", u.first); return 0; }

Compilation message (stderr)

politicari.cpp: In function 'int main()':
politicari.cpp:37:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 0; i < v.size(); ++i)
                             ~~^~~~~~~~~~
politicari.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%lld", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~
politicari.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...