답안 #583621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
583621 2022-06-25T18:47:12 Z AGE Političari (COCI20_politicari) C++14
컴파일 오류
0 ms 0 KB
#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[1000][1000];
map<pair<int,int>,int>viss;
vector<pair<int,int>>v;
pair<int,int>anss;
main()
{
    v.clear();
    anss={0,0};
    viss.clear();

    int n,m;
    cin>>n>>m;

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

    v.pb({0,1});
    v.pb({1,2});

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

    while(1){

        int x=v.length()-1;

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


        viss[{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]});

    }

    //assert(v.size()>20);
    reverse(v.begin(),v.end());
    while((v.size())&&((*v.rbegin()).F!=anss.F||(*v.rbegin()).S!=anss.S)&&m>0)
        v.pop_back(),m--;


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

    int xx=m%v.size();

    if(xx==0)
        xx=v.size();

    xx--;

   // assert(v[xx].S>12);
    cout<<v[xx].S<<endl;

    return 0;
}

Compilation message

politicari.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      | ^~~~
politicari.cpp: In function 'int main()':
politicari.cpp:33:17: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'length'
   33 |         int x=v.length()-1;
      |                 ^~~~~~