답안 #732254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
732254 2023-04-28T20:19:44 Z vjudge1 Političari (COCI20_politicari) C++17
10 / 70
20 ms 4248 KB
// author: MisterReaper (Ahmet Alp Orakci)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int) x.size()
#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
    #include "debug.h"
    #define OPEN freopen(".in", "r", stdin); freopen(".out", "w", stdout);
    #define TIME cerr << "\n" << fixed << setprecision(2) << 1000.0 * clock() / CLOCKS_PER_SEC << " milliseconds ";
#else
    #define debug(...) void(23)
    #define OPEN void(0000)
    #define TIME void(232323233)
#endif

void solve()
{
    int n, k; cin >> n >> k;
    int arr[n +1][n +1], vis[n +1][n +1];
    memset(vis, 0, sizeof(vis));

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> arr[j][i];
        }
    }

    vector <int> v;
    v.emplace_back(1);
    v.emplace_back(2);

    while(true)
    {
        if(vis[v[sz(v) - 2]][v.back()]) break;
        vis[v[sz(v) - 2]][v.back()] = 1;

        v.emplace_back(arr[v[sz(v) - 2]][v.back()]);
    }
    v.pop_back();
    v.pop_back();

    k %= sz(v);
    cout << v[(k -1 + sz(v)) % sz(v)];
    
    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    while(t--)
    {
        solve();
    }

    TIME;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 3 ms 980 KB Output isn't correct
3 Incorrect 10 ms 2800 KB Output isn't correct
4 Incorrect 12 ms 3504 KB Output isn't correct
5 Incorrect 16 ms 4244 KB Output isn't correct
6 Incorrect 15 ms 4248 KB Output isn't correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 1 ms 596 KB Output isn't correct
9 Incorrect 4 ms 1108 KB Output isn't correct
10 Incorrect 14 ms 3412 KB Output isn't correct
11 Incorrect 18 ms 4244 KB Output isn't correct
12 Incorrect 20 ms 4244 KB Output isn't correct
13 Incorrect 1 ms 340 KB Output isn't correct
14 Incorrect 1 ms 596 KB Output isn't correct