제출 #332268

#제출 시각아이디문제언어결과실행 시간메모리
332268zggf곤돌라 (IOI14_gondola)C++14
75 / 100
30 ms4464 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]) { long long offset = -1; unordered_map<int, bool> odw; for(long long i = 0; i < n; i++){ if(odw[inputSeq[i]]) return 0; odw[inputSeq[i]] = true; if(inputSeq[i]<=n){ long long tmp = (n+inputSeq[i]-i)%n; if(offset==-1) offset = tmp; if(tmp!=offset) return 0; } } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { long long offset = -1; priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> q; for(long long i = 0; i < n; i++){ if(gondolaSeq[i]<=n){ long long tmp = (n+gondolaSeq[i]-i-1)%n; if(offset==-1) offset = tmp; }else{ q.push(make_pair(gondolaSeq[i], i)); } } if(offset==-1) offset=0; for(long long i = 0; i < n; i++){ gondolaSeq[i] = 1+(i+offset)%n; } long long cur = n+1; for(long long i = 0; !q.empty(); i++){ if(gondolaSeq[q.top().second] < q.top().first){ replacementSeq[i] = gondolaSeq[q.top().second]; gondolaSeq[q.top().second] = cur; cur++; }else{ q.pop(); i--; } } return cur-n-1; return -2; } //---------------------- long long mod = 1e9+9; long long pot(long long a, long long b){ if(b==0) return 1; if(b%2==0){ long long cur = pot(a, b/2); return (cur*cur)%mod; }else return (a*pot(a, b-1))%mod; } int countReplacement(int n, int inputSeq[]) { vector<long long> tab; long long offset = -1; long long wyn = 1; long long cnt = 0; unordered_map<int, bool> odw; for(long long i = 0; i < n; i++){ if(odw[inputSeq[i]]) return 0; odw[inputSeq[i]] = true; if(inputSeq[i]<=n){ long long tmp = (n+inputSeq[i]-i)%n; if(offset==-1) offset = tmp; if(tmp!=offset) return 0; }else{ cnt++; tab.push_back(inputSeq[i]); } } sort(tab.begin(), tab.end()); long long cur = n+1; for(long long i = 0; i < tab.size(); i++){ wyn*=pot(cnt, tab[i]-cur); wyn%=mod; cur=tab[i]+1; cnt--; } return wyn; }

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

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:90:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |  for(long long i = 0; i < tab.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...