제출 #602240

#제출 시각아이디문제언어결과실행 시간메모리
602240Vanilla곤돌라 (IOI14_gondola)C++17
45 / 100
39 ms4452 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; int valid(int n, int a[]){ map <int, int> mp; for (int i = 0; i < n; i++){ if (mp.count(a[i])) return 0; mp[a[i]] = i; } for (int i = 0; i < n; i++){ if (a[i] < n && mp.count(a[i] + 1) && mp[a[i] + 1] != (i + 1) % n) return 0; } return 1; } //---------------------- int replacement(int n, int a[], int rs[]){ const int maxv = 2e5 + 5e4; int in[n] = {}; int l = 0; int ct = n + 1; int ps = -1; vector <pair <int, int> > v; for (int i = 0; i < n; i++){ v.push_back({a[i], i}); if (a[i] <= n) ps = i; } sort(v.begin(), v.end()); if (ps == -1){ for (int i = 0; i < n; i++) in[i] = i + 1; } else { for (int i = ps, v = a[ps]; !in[i]; i = (i + 1) % n, v = v % n + 1) in[i] = v; } for (auto [val, pos]: v) { while (in[pos] != val) { rs[l++] = in[pos]; in[pos] = ct++; } } // for (int i = 0; i < n; i++){ // cout << in[i] << " "; // } // cout << '\n'; return l; } //---------------------- int countReplacement(int n, int inputSeq[]){ return -3; }

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

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:20:12: warning: unused variable 'maxv' [-Wunused-variable]
   20 |  const int maxv = 2e5 + 5e4;
      |            ^~~~
#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...