제출 #599271

#제출 시각아이디문제언어결과실행 시간메모리
599271Koosha_mv곤돌라 (IOI14_gondola)C++14
75 / 100
18 ms2384 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=1e5+99,mod=1e9+9; int mark[N]; ll pow(ll x,ll y,ll mod){return(!y?1:pow(x*x%mod,y/2,mod)*(y&1?x:1))%mod;} int valid(int n, int inputSeq[]){ f(i,0,n) inputSeq[i]--; f(i,0,n) if(++mark[inputSeq[i]]>1) return 0; f(i,0,n){ if(inputSeq[i]<n){ f(j,0,n){ if(inputSeq[(i+j)%n]!=(inputSeq[i]+j)%n && inputSeq[(i+j)%n]<n) return 0; } return 1; } } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]){ vector<pair<int,int>> vec; f(i,0,n) gondolaSeq[i]--; int b=0,l=0; f(i,0,n){ if(gondolaSeq[i]<n){ b=1; f(j,0,n){ if(gondolaSeq[(i+j)%n]>=n){ vec.pb(mp(gondolaSeq[(i+j)%n],(gondolaSeq[i]+j)%n)); } } break ; } } if(b==0){ f(i,0,n){ vec.pb({gondolaSeq[i],i}); } } sort(all(vec)); int prv=n-1; for(auto p : vec){ replacementSeq[l++]=p.S; f(i,prv+1,p.F) replacementSeq[l++]=i; prv=p.F; } f(i,0,l) replacementSeq[i]++; return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { vector<pair<int,int>> vec; f(i,0,n) inputSeq[i]--,mark[inputSeq[i]]=0; f(i,0,n) if(++mark[inputSeq[i]]>1) return 0; int b=0; f(i,0,n){ if(inputSeq[i]<n){ b=1; f(j,0,n){ if(inputSeq[(i+j)%n]!=(inputSeq[i]+j)%n && inputSeq[(i+j)%n]<n){ return 0; } if(inputSeq[(i+j)%n]>=n){ vec.pb(mp(inputSeq[(i+j)%n],(inputSeq[i]+j)%n)); } } break ; } } if(b==0){ f(i,0,n){ vec.pb({inputSeq[i],i}); } } sort(all(vec)); int prv=n-1,ans=1; f(i,0,vec.size()){ pair<int,int> p=vec[i]; int cnt=vec.size()-i; //cout<<cnt<<" -> "<<p.F-prv<<endl; ans=1ll*ans*pow(cnt,p.F-prv-1,mod)%mod; prv=p.F; } return ans; }

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

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define f(i,a,b) for(int i=a;i<b;i++)
......
  106 |   f(i,0,vec.size()){
      |     ~~~~~~~~~~~~~~             
gondola.cpp:106:3: note: in expansion of macro 'f'
  106 |   f(i,0,vec.size()){
      |   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...