제출 #242443

#제출 시각아이디문제언어결과실행 시간메모리
242443joseacaz곤돌라 (IOI14_gondola)C++17
55 / 100
31 ms4568 KiB
#include "gondola.h" #include <bits/stdc++.h> #define pb push_back #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; const int MAXN = 1e6 + 5; vi input; unordered_map<int, int> vis; int valid(int N, int inputSeq[]) { input.clear(); for(int i = 0; i < N; i++) input.pb(inputSeq[i]); int ans = 0, one = 0; vis.clear(); for(int i = 0; i < N; i++) { if(vis[input[i]]) return 0; vis[input[i]]++; } for(int i = 0; i < N; i++) { if(input[i] <= N) { one = 1; int idx; for(int j = 0; j < N; j++) { idx = (i + (j + 1 - input[i]) + N) % N; if(input[idx] == j + 1 || input[idx] > N) ans++; } cerr << i << " " << input[i] << " " << ans << "\n"; break; } } if(!one) return 1; return (ans == N); } int replacement(int N, int gondolaSeq[], int replacementSeq[]) { input.clear(); for(int i = 0; i < N; i++) input.pb(gondolaSeq[i]); int one = 0; for(int i = 0; i < N; i++) if(input[i] <= N) one = (i - input[i] + 1 + N) % N; vpi seq; for(int i = 0; i < N; i++) seq.pb({input[(one + i) % N], i + 1}); sort(all(seq)); int curr = 0, newGondola = N + 1; for(int i = 0; i < N; i++) { while(seq[i].second != seq[i].first) { replacementSeq[curr++] = seq[i].second; seq[i].second = newGondola++; } } return curr; } int countReplacement(int N, int inputSeq[]) { return 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...