| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 210021 | apostoldaniel854 | Političari (COCI20_politicari) | C++14 | 26 ms | 2168 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
https://oj.uz/problem/view/COCI20_politicari
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
const int N = 500;
int politician[1 + N * N + 4];
int nxt[1 + N][1 + N];
int used[1 + N][1 + N];
int main() {
ios::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
ll k;
int n;
cin >> n >> k;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
cin >> nxt[i][j];
nxt[1][0] = 2;
int start, blamed;
blamed = 0;
start = 1;
int step = 0;
while (used[start][blamed] == 0) {
used[start][blamed] = ++step;
politician[step] = start;
int cur = nxt[start][blamed];
blamed = start;
start = cur;
}
if (k < used[start][blamed]) {
cout << politician[k] << "\n";
}
else {
k -= used[start][blamed];
int period = step - used[start][blamed] + 1;
cout << politician[used[start][blamed] + k % period] << "\n";
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
