# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
731399 | 2023-04-27T11:47:26 Z | eneskav | Političari (COCI20_politicari) | C++17 | 2 ms | 340 KB |
#include <iostream> #include <vector> #include <cstring> #define int long long using namespace std; #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); signed main() { fastio; freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int n, k; cin >> n >> k; int a[n + 1][n + 1]; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) cin >> a[i][j]; if (k <= 2) { cout << k; return 0; } bool vis[n + 1][n + 1]; memset(vis, false, sizeof(vis)); int p = 0, c = 1; vector<int> v; v.push_back(1); a[c][p] = 2; for (int i = 1; i < k * 2; ++i) { int t = c; c = a[c][p]; p = t; if (vis[c][p]) { v.pop_back(); break; } vis[c][p] = true; v.push_back(c); } // print v /* for (auto i : v) cout << i << " "; cout << endl; */ cout << v[(k - 1) % v.size()]; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Incorrect | 2 ms | 340 KB | Output isn't correct |
3 | Incorrect | 2 ms | 340 KB | Output isn't correct |
4 | Incorrect | 2 ms | 340 KB | Output isn't correct |
5 | Incorrect | 2 ms | 340 KB | Output isn't correct |
6 | Incorrect | 2 ms | 340 KB | Output isn't correct |
7 | Incorrect | 2 ms | 340 KB | Output isn't correct |
8 | Incorrect | 2 ms | 340 KB | Output isn't correct |
9 | Incorrect | 2 ms | 340 KB | Output isn't correct |
10 | Incorrect | 2 ms | 340 KB | Output isn't correct |
11 | Incorrect | 2 ms | 340 KB | Output isn't correct |
12 | Incorrect | 2 ms | 340 KB | Output isn't correct |
13 | Incorrect | 2 ms | 340 KB | Output isn't correct |
14 | Incorrect | 2 ms | 340 KB | Output isn't correct |