제출 #319923

#제출 시각아이디문제언어결과실행 시간메모리
319923wildturtle곤돌라 (IOI14_gondola)C++14
90 / 100
30 ms2528 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; int a,b,c,d,i,e,f,g,m,k,l,idx,mod,B[500005],pas; long long xarisxad(long long base,long long power) { long long result=1; while(power>0) { if(power%2==1) result=(result*base)%mod; base=(base*base)%mod; power/=2; } return result; } int valid(int n,int A[]) { idx=-1; for(int i=0;i<n;i++) { if(A[i]<=n) { idx=i; break; } } if(idx==-1) return 1; a=A[idx]; for(int i=idx;i<n;i++) { if(A[i]>n) { a++; a%=(n+1); if(a==0) a++; continue; } if(A[i]!=a) return 0; a++; a%=(n+1); if(a==0) a++; } for(int i=0;i<idx;i++) { if(A[i]>n) { a++; a%=(n+1); if(a==0) a++; continue; } if(A[i]!=a) return 0; a++; a%=(n+1); if(a==0) a++; } return 1; } int replacement(int n,int A[],int ans[]) { idx=-1; for(int i=0;i<n;i++) { if(A[i]<=n) { idx=i; break; } } a=A[idx]; for(int i=idx;i<n;i++) { B[i]=a; a++; a%=(n+1); if(a==0) a++; } for(int i=0;i<idx;i++) { B[i]=a; a++; a%=(n+1); if(a==0) a++; } vector < pair < int , int > > v; for(int i=0;i<n;i++) { if(A[i]>n) v.push_back({A[i],i}); } sort(v.begin(),v.end()); k=n; for(int i=0;i<v.size();i++) { while(B[v[i].second]<A[v[i].second]) { ans[pas]=B[v[i].second]; pas++; k++; B[v[i].second]=k; } } return pas; } int countReplacement(int n,int A[]) { if(valid(n, A)==0) return 0; vector <int> v; v.push_back(n); for(int i=0;i<n;i++) { if(A[i]>n) v.push_back(A[i]); } sort(v.begin(),v.end()); long long ans1=1; mod=1000000009; for(int i=0;i<v.size()-1;i++) { ans1*=xarisxad(v.size()-i-1,v[i+1]-v[i]-1); ans1%=mod; } if(v.size()==n+1) { ans1*=n; ans1%=mod; } return ans1; }

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

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0;i<v.size();i++) {
      |                 ~^~~~~~~~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:81:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for(int i=0;i<v.size()-1;i++) {
      |                 ~^~~~~~~~~~~
gondola.cpp:85:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   85 |     if(v.size()==n+1) { ans1*=n; ans1%=mod; }
      |        ~~~~~~~~^~~~~
#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...