제출 #980932

#제출 시각아이디문제언어결과실행 시간메모리
980932SmuggingSpun곤돌라 (IOI14_gondola)C++14
55 / 100
16 ms2768 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]){ vector<pair<int, int>>p; const int LIM = 250001; vector<bool>cnt(LIM, false); for(int i = 0; i < n; i++){ if(inputSeq[i] <= n){ p.emplace_back(inputSeq[i], i); } else if(cnt[inputSeq[i]]){ return 0; } else{ cnt[inputSeq[i]] = true; } } sort(p.begin(), p.end()); for(int i = 1; i < p.size(); i++){ if((p[i].second < p[i - 1].second && (p[i].second += n) < p[i - 1].second) || (p[i].second - p[i - 1].second != p[i].first - p[i - 1].first)){ return 0; } } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ if(!valid(n, gondolaSeq)){ return 0; } int index = min_element(gondolaSeq, gondolaSeq + n) - gondolaSeq, L = 0; if(gondolaSeq[index] > n){ vector<int>p(n), init(n); iota(p.begin(), p.end(), 0); iota(init.begin(), init.end(), 1); sort(p.begin(), p.end(), [&] (int i, int j) -> bool{ return gondolaSeq[i] < gondolaSeq[j]; }); int current = n; for(int& i : p){ while(gondolaSeq[i] > init[i]){ replacementSeq[L++] = init[i]; init[i] = ++current; } } } else{ vector<int>init(n); for(int i = 0; i < n; i++){ init[(i + index) % n] = (gondolaSeq[index] - 1 + i) % n + 1; } vector<int>p; for(int i = 0; i < n; i++){ if(gondolaSeq[i] > n){ p.emplace_back(i); } } sort(p.begin(), p.end(), [&] (int i, int j) -> bool{ return gondolaSeq[i] < gondolaSeq[j]; }); int current = n; for(int& i : p){ while(gondolaSeq[i] > init[i]){ replacementSeq[L++] = init[i]; init[i] = ++current; } } } return L; } int countReplacement(int n, int inputSeq[]){ }

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

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20: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]
   20 |  for(int i = 1; i < p.size(); i++){
      |                 ~~^~~~~~~~~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:72:1: warning: no return statement in function returning non-void [-Wreturn-type]
   72 | }
      | ^
#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...