제출 #340091

#제출 시각아이디문제언어결과실행 시간메모리
340091HazemPolitičari (COCI20_politicari)C++14
70 / 70
365 ms140416 KiB
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/

#include <bits/stdc++.h>
using namespace std;

#define S second
#define F first
#define LL long long
const int N = 5e2 + 10;


LL LINF = 100000000000000000;
LL INF = 1000000000;

pair<int,int> nxt[N][N][70];

int main()
{
    //freopen("out.txt","w",stdout);
    LL n,k;
    scanf("%lld%lld",&n,&k);

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            int x;cin>>x;
            nxt[i][j][0] = {x,i};
        }
    
    if(k==1){
        puts("1");
        return 0;
    }

    for(int j=1;j<=60;j++)
        for(int i=1;i<=n;i++)
            for(int k=1;k<=n;k++){
                if(k==i)continue;
                pair<int,int>p = nxt[i][k][j-1];
                nxt[i][k][j] = nxt[p.F][p.S][j-1];
            }

    k -= 2;
    pair<int,int>cur = {2,1};
    for(LL i=60;i>=0;i--)
        if((1ll<<i)<=k)
        cur = nxt[cur.F][cur.S][i],k -= 1ll<<i;
    
    printf("%d\n",cur.F);
}       

컴파일 시 표준 에러 (stderr) 메시지

politicari.cpp: In function 'int main()':
politicari.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%lld%lld",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...