제출 #161092

#제출 시각아이디문제언어결과실행 시간메모리
161092InfiniteJest곤돌라 (IOI14_gondola)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <fstream> #include <vector> #include <queue> #include <algorithm> #include <math.h> #include "gondola.h" #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); int valid(int n, int inputSeq[]){ int ans=1; bool pres[300001]; for(int i=0;i<n;i++){ if(inputSeq[i]<=n){ int val=inputSeq[i]; for(int y=0;y<n;y++){ if((inputSeq[(i+y)%n]<=n&&inputSeq[(i+y)%n]!=val)/*||pres[inputSeq[(i+y)%n]]*/){ ans=0; break; } val++; if(val==n+1)val=1; //pres[inputSeq[(i+y)%n]]=1; } break; } } for(int i=0;i<n;i++){ if(pres[inputSeq[i]])ans=0; pres[inputSeq[i]]=1; } return ans; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ bool flag=0; vector<pair<int,int> > p; int ind=-1,val; for(int i=0;i<n;i++){ if(gondolaSeq[i]<=n){ ind=i; val=gondolaSeq[i]; } else flag=1; } if(!flag)return 0; if(ind==-1){ ind=0; val=1; } for(int i=0;i<n;i++){ if(gondolaSeq[(ind+i)%n]>n){ flag=1; p.pb(mp(gondolaSeq[(ind+i)%n],val)); //cout<<gondolaSeq[(ind+i)%n]; } val++; if(val==n+1)val=1; } sort(p.begin(),p.end()); int cur=n+1; int indtot=0; for(int i=0;i<p.size();i++){ replacementSeq[indtot++]=p[i].se; for(;cur<p[i].fi;cur++)replacementSeq[indtot++]=cur; cur=p[i].fi+1; } //for(int i=0;i<indtot;i++)cout<<replacementSeq[i]<<" "; return indtot; } int countReplacement(int n, int inputSeq[]){ if(!valid(n,inputSeq))return 0; int tot=0; bool pres[300000]; int mas=-1; for(int i=0;i<n;i++){ if(inputSeq[i]>n){ tot++; pres[inputSeq[i]]=1; mas=max(mas,inputSeq[i]); } } if(tot==0)return 1; int sol=1; for(int i=n+1;i<=mas;i++){ if(pres[i]){ if(tot==n)sol=(sol%mod*n%mod)%mod; tot--; } else{ sol=(sol%mod*tot%mod)%mod; } } return sol; }

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

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:71:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<p.size();i++){
                 ~^~~~~~~~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:96:26: error: 'mod' was not declared in this scope
       if(tot==n)sol=(sol%mod*n%mod)%mod;
                          ^~~
gondola.cpp:96:26: note: suggested alternative: 'modf'
       if(tot==n)sol=(sol%mod*n%mod)%mod;
                          ^~~
                          modf
gondola.cpp:100:16: error: 'mod' was not declared in this scope
       sol=(sol%mod*tot%mod)%mod;
                ^~~
gondola.cpp:100:16: note: suggested alternative: 'modf'
       sol=(sol%mod*tot%mod)%mod;
                ^~~
                modf