제출 #583208

#제출 시각아이디문제언어결과실행 시간메모리
583208AGEPolitičari (COCI20_politicari)C++14
0 / 70
56 ms2308 KiB
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define int long long

using namespace std;
const int N=1e6,M=2e3,mod=1e9+7;
int a[510][510];
map<pair<int,int>,int>vis;
main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];

    vector<pair<int,int>>v;
    v.pb({0,1});
    v.pb({1,2});

    vis[{0,1}]=1;
    vis[{1,2}]=1;

    pair<int,int>ans;
    while(1){

        int x=v.size()-1;

        if(vis[{v[x].S,a[v[x].S-1][v[x].F-1]}]==1){
            ans.F=v[x].S;
            ans.S=a[v[x].S-1][v[x].F-1];
            break;
        }

        vis[{v[x].S,a[v[x].S-1][v[x].F-1]}]=1;
        v.pb({v[x].S,a[v[x].S-1][v[x].F-1]});

    }


    reverse(v.begin(),v.end());
    pair<int,int> lst={-1,-1};
    while(((*v.rbegin()).F!=ans.F||(*v.rbegin()).S!=ans.S)&&m>0){

        lst=*v.rbegin();
        v.pop_back(),m--;

    }

    if(m==0){
        cout<<lst.F<<" "<<lst.S<<endl;
        return 0;
    }

    reverse(v.begin(),v.end());

    int xx;
    if(m>=v.size()){

        m%v.size();
        if(xx==0)
            xx=v.size();
        xx--;

    }
    xx--;


    cout<<v[xx].S<<endl;
    return 0;
}

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

politicari.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
politicari.cpp: In function 'int main()':
politicari.cpp:61:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     if(m>=v.size()){
      |        ~^~~~~~~~~~
politicari.cpp:63:10: warning: value computed is not used [-Wunused-value]
   63 |         m%v.size();
      |         ~^~~~~~~~~
politicari.cpp:64:9: warning: 'xx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   64 |         if(xx==0)
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...