제출 #285524

#제출 시각아이디문제언어결과실행 시간메모리
2855242qbingxuan곤돌라 (IOI14_gondola)C++14
25 / 100
29 ms1664 KiB
#include "gondola.h" #include <bits/stdc++.h> #ifdef local #define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__) void qqbx(const char *s) {} template <typename H, typename ...T> void qqbx(const char *s, const H& h, T&& ...args) { for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s; std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n"); if(sizeof...(T)) qqbx(++s, args...); } #define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n" #else #define debug(...) ((void)0) #define safe ((void)0) #endif // local #define pb emplace_back #define all(v) begin(v),end(v) using namespace std; int valid(int n, int inputSeq[]) { vector<int> v(inputSeq, inputSeq+n), u = v; sort(u.begin(), u.end()); for(int i = 1; i < n; i++) if(u[i] == u[i-1]) return false; for(int &x: v) --x; queue<int> q; for(int i = 0; i < n; i++) if(v[i] < n) q.push(i); while(!q.empty()) { int i = q.front(); q.pop(); int j = (i+1)%n; if(v[j] >= n) { v[j] = (v[i]+1)%n; q.push(j); } else if(v[j] != (v[i]+1)%n) { return false; } } return true; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int L = 0; int tot = n; vector<int> v(gondolaSeq, gondolaSeq+n), org = v; { for(int &x: org) --x; queue<int> q; for(int i = 0; i < n; i++) if(org[i] < n) q.push(i); while(!q.empty()) { int i = q.front(); q.pop(); int j = (i+1)%n; if(org[j] >= n) { org[j] = (org[i]+1)%n; q.push(j); } else { assert(org[j] == (org[i]+1)%n); } } for(int &x: org) ++x; } vector<pair<int,int>> evt; for(int i = 0; i < n; i++) if(v[i] > n) evt.pb(v[i], i); sort(evt.begin(), evt.end()); for(int i = 0; i < int(evt.size()); i++) while(tot < evt[i].first) replacementSeq[L++] = org[evt[i].second], org[evt[i].second] = ++tot; return L; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }
#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...