제출 #500758

#제출 시각아이디문제언어결과실행 시간메모리
500758InternetPerson10곤돌라 (IOI14_gondola)C++17
25 / 100
18 ms3148 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1000000009; int valid(int n, int inputSeq[]) { vector<int> nums(n); for(int i = 0; i < n; i++) { nums[i] = inputSeq[i]; } sort(nums.begin(), nums.end()); int mi = nums[n-1]; for(int i = 0; i < n-1; i++) { if(nums[i] == nums[i+1]) return 0; mi = min(mi, nums[i]); } int k = 0; for(int i = 0; i < n; i++) { if(mi == inputSeq[i]) k = i; } k -= mi; k += (n+1); k %= n; for(int i = 0; i < n; i++) { nums[i] = inputSeq[(k+i)%n]; } for(int i = 0; i < n; i++) { if(nums[i] <= n && nums[i] != i+1) return 0; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vector<int> nums(n); int mi = MOD; for(int i = 0; i < n; i++) nums[i] = gondolaSeq[i]; for(int i = 0; i < n; i++) { mi = min(mi, nums[i]); } int k = 0; for(int i = 0; i < n; i++) { if(mi == gondolaSeq[i]) k = i; } k -= mi; k += (n+1); k %= n; for(int i = 0; i < n; i++) { nums[i] = gondolaSeq[(k+i)%n]; } vector<pair<int, int>> v; for(int i = 0; i < n; i++) { v.push_back({nums[i], i+1}); } sort(v.begin(), v.end()); int g = 0; for(int i = 0; i < v.size(); i++) { while(v[i].second != v[i].first) { replacementSeq[g] = v[i].second; v[i].second = g+n+1; g++; } } return g; } int countReplacement(int n, int inputSeq[]) { return -3; }

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

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     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...