제출 #716148

#제출 시각아이디문제언어결과실행 시간메모리
716148Baytoro곤돌라 (IOI14_gondola)C++17
55 / 100
48 ms6156 KiB
#include "gondola.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; int valid(int n, int a[]){ map<int,int> mp; for(int i=0;i<n;i++){ if(mp[a[i]]!=0) return 0; mp[a[i]]=1; } vector<pair<int,int>> v; for(int i=0;i<n;i++){ if(a[i]<=n){ v.push_back({a[i],i}); } } sort(v.begin(),v.end()); for(int i=1;i<(int)v.size();i++){ int k=(v[i].first-v[i-1].first); int s=(v[i].second-v[i-1].second+n)%n; if(k!=s) return 0; } return 1; } //---------------------- bool cmp(pair<int,int> a, pair<int,int> b){ return a.second<b.second; } int replacement(int n, int a[], int ans[]){ for(int i=0;i<n;i++) a[i]--; bool ok=0; vector<pair<int,int>> v; for(int i=0;i<n;i++){ if(a[i]<n){ ok=1; for(int j=1;j<n;j++){ if(a[(j+i)%n]>=n){ v.push_back({(a[i]+j)%n,a[(i+j)%n]}); } } break; } } if(!ok && v.empty()){ for(int i=0;i<n;i++) v.push_back({i,a[i]}); } sort(v.begin(),v.end(),cmp); int cnt=0; for(auto it: v){ int l=it.first,r=it.second; while(l!=r){ ans[cnt]=l+1; l=n+cnt; cnt++; } } return cnt; } //---------------------- 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...