제출 #320102

#제출 시각아이디문제언어결과실행 시간메모리
320102tigicha곤돌라 (IOI14_gondola)C++17
55 / 100
50 ms6116 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; long long k, l, b[100005], sum; map<long long,long long>mp; vector<pair<long long, long long> >v; vector<long long>vec; long long pow(long long x, long long y){ long long s=1; while(y>0){ if(y%2==1) s=(s*x)%1000000009; x=(x*x)%1000000009; y/=2; } return s; } int valid(int n, int a[]){ l=-1; for(int i=0; i<n; i++) if(mp[a[i]]==1) return 0; else mp[a[i]]=1; for(int i=0; i<n; i++) if(a[i]<=n){ l=i; break; } if(l==-1) return 1; k=a[l]; for(int i=l; i<n; i++) if(a[i]!=k && a[i]<=n) return 0; else{ k++; if(k==n+1) k=1; } for(int i=0; i<l; i++) if(a[i]!=k && a[i]<=n) return 0; else{ k++; if(k==n+1) k-=n; } return 1; } int replacement(int n, int a[], int ans[]){ l=-1; for(int i=0; i<n; i++) if(a[i]<=n){ l=i; break; } k=a[l]; for(int i=l; i<n; i++){ b[i]=k; k++; if(k==n+1) k-=n; } for(int i=0; i<l; i++){ b[i]=k; k++; if(k==n+1) k=1; } for(int i=0; i<n; i++) if(a[i]>n) v.push_back({a[i], i}); sort(v.begin(), v.end()); l=n; k=0; for(int i=0; i<v.size(); i++) while(b[v[i].second]<a[v[i].second]){ ans[k]=b[v[i].second]; k++; l++; b[v[i].second]=l; } return k; } int countReplacement(int n, int a[]){ if(valid(n, a)==0) return 0; vec.push_back(n); for(int i=0; i<n; i++) if(a[i]>n) vec.push_back(a[i]); sort(vec.begin(), vec.end()); for(int i=0; i<vec.size()-1; i++){ sum*=pow(vec.size()-i-1, vec[i+1]-vec[i]-1); sum%=1000000009; } if(vec.size()==n+1) sum=(sum*n)%1000000009; return sum; }

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

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