제출 #787913

#제출 시각아이디문제언어결과실행 시간메모리
787913Minindu206곤돌라 (IOI14_gondola)C++14
20 / 100
32 ms4668 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]) { int ind = -1; map<int, int> mp; for (int i = 0; i < n; i++) { if (mp[inputSeq[i]] == 1) return 0; if (inputSeq[i] <= n) ind = i; mp[inputSeq[i]] = 1; } if (ind == -1) return 1; for (int i = 0; i < n; i++) { if (inputSeq[i] > n) continue; if (((inputSeq[ind] - inputSeq[i] + n) % n) != ((ind - i + n) % n)) return 0; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int ind = -1, mx = 0, l; map<int, int> mp; for (int i = 0; i < n; i++) { if (gondolaSeq[i] <= n) ind = i; mx = max(gondolaSeq[i], mx); } l = mx - n; vector<pair<int, int>> reps; if (ind == -1) { for (int i = 1; i < n + 1; i++) reps.push_back({gondolaSeq[i - 1], i}); } else { for (int i = 0; i < n; i++) { if (gondolaSeq[i] <= n) continue; int dis = 0; if(i > ind) dis = i - ind; else dis = n - ind + i; int val = gondolaSeq[ind] + dis; if(val > n) val = val % n; reps.push_back({gondolaSeq[i], val}); } } sort(reps.begin(), reps.begin()); int i = 0, j = n + 1, k = 0; for(int k=0;i<reps.size();i++) { pair<int, int> cur = reps[k]; replacementSeq[i] = cur.second; i++; while(j < cur.first) { replacementSeq[i] = j; j++; i++; } j++; } return i; } int countReplacement(int n, int inputSeq[]) { return -3; }

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

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:64:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |   for(int k=0;i<reps.size();i++)
      |               ~^~~~~~~~~~~~
gondola.cpp:30:25: warning: variable 'l' set but not used [-Wunused-but-set-variable]
   30 |   int ind = -1, mx = 0, l;
      |                         ^
gondola.cpp:63:25: warning: unused variable 'k' [-Wunused-variable]
   63 |   int i = 0, j = n + 1, k = 0;
      |                         ^
#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...