제출 #521282

#제출 시각아이디문제언어결과실행 시간메모리
521282sofapuden곤돌라 (IOI14_gondola)C++14
60 / 100
39 ms4548 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; const int M = 1e9+9; int pw(int a, int b){ int r = 1; while(b){ if(b&1)r = 1ll*r*a%M; b>>=1; a = 1ll*a*a%M; } return r; } int valid(int n, int inputSeq[]){ set<int> S; int x = 0; for(int i = 0; i < n; ++i){ if(S.count(inputSeq[i]))return 0; S.insert(inputSeq[i]); if(inputSeq[i] <= n)x = (inputSeq[i]-i+n-1)%(n)+1; } for(int i = 0; i < n; ++i){ if(inputSeq[i] != (x+i-1)%(n)+1 && inputSeq[i] <= n)return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]){ vector<pair<int,int>> v; int x = 1; for(int i = 0; i < n; ++i){ if(gondolaSeq[i] <= n)x = (gondolaSeq[i]-i+n-1)%(n)+1; } for(int i = 0; i < n; ++i){ if(gondolaSeq[i] > n){ v.emplace_back(gondolaSeq[i],(x+i-1)%n+1); } } sort(v.begin(),v.end()); int cn = 0; for(int i = 0; i < v.size(); ++i){ replacementSeq[cn++] = v[i].second; while(cn + n < v[i].first){ replacementSeq[cn] = cn+n; cn++; } } return cn; } //---------------------- int countReplacement(int n, int gondolaSeq[]){ if(!valid(n,gondolaSeq))return 0; vector<int> v; for(int i = 0; i < n; ++i){ if(gondolaSeq[i] > n){ v.emplace_back(gondolaSeq[i]); } } sort(v.begin(),v.end()); int z = v.size(); if(z == 0)return 1; int ans = pw(z,v[0]-n-1); for(int i = 1; i < z; ++i){ ans = 1ll * ans * pw(z-i-1,v[i]-v[i-1]-1) % M; } return ans; }

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

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