제출 #288964

#제출 시각아이디문제언어결과실행 시간메모리
288964Shafin666곤돌라 (IOI14_gondola)C++14
25 / 100
43 ms4728 KiB
#include "gondola.h" #include <bits/stdc++.h> #define pb push_back #define pii pair<ll, ll> #define nyan "(=^・ω・^=)" #define read_input freopen("in.txt","r", stdin) #define print_output freopen("out.txt","w", stdout) typedef long long ll; typedef long double ld; using namespace std; const int maxn = 3e5+10; int next(int p, int n) { int ret = (p + 1) % n; return (ret == 0)? n : ret; } int prev(int p, int n) { if(p == 0) return n-1; else return p-1; } int valid(int n, int inputSeq[]) { int f = 1, prev = -1; for(int i = 0; i < n; i++) { if(inputSeq[i] >= 1 && inputSeq[i] <= n) { if(prev == -1) prev = inputSeq[i]; else if(next(prev, n) == inputSeq[i]) prev = inputSeq[i]; else f = 0; } } set<int> s; for(int i = 0; i < n; i++) s.insert(inputSeq[i]); if(s.size() != n) return 0; return f; } //---------------------- int pos[maxn]; int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vector<int> v; int dummy, mx = 0; for(int i = 0; i < n; i++) { if(gondolaSeq[i] > n) { dummy = i; pos[gondolaSeq[i]] = i; mx = max(mx, gondolaSeq[i]); } } for(int i = 0; i < n; i++) { if(gondolaSeq[prev(i, n)] >= 1 && gondolaSeq[prev(i, n)] <= n) gondolaSeq[i] = next(gondolaSeq[prev(i, n)], n); } for(int i = n+1; i <= mx; i++) { if(!pos[i]) v.pb(gondolaSeq[dummy]), gondolaSeq[dummy] = i; else v.pb(gondolaSeq[pos[i]]), gondolaSeq[pos[i]] = i; } int idx = 0; for(auto i : v) replacementSeq[idx++] = i; return v.size(); } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

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

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:37:14: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |  if(s.size() != n) return 0;
      |     ~~~~~~~~~^~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:65:31: warning: 'dummy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   65 |   if(!pos[i]) v.pb(gondolaSeq[dummy]), gondolaSeq[dummy] = 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...