# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
819652 |
2023-08-10T12:22:35 Z |
kebine |
Gondola (IOI14_gondola) |
C++17 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "gondola.h"
#define ll long long
#define mod 1000000007
using namespace std;
//~ int n;
//~ int inputSeq[1000];
int replacement(int n, int inputSeq[], int replacementSeq[]){
int mn = INT_MAX;
int id;
map<int,int> cnt;
for(int i = 0 ; i < n ; i++){
cnt[inputSeq[i]]++;
if( cnt[inputSeq[i]] > 1 ) return 0;
}
for(int i = 0 ; i < n ; i++){
if( mn > inputSeq[i] ){
mn = inputSeq[i];
id = i;
}
}
if( mn > n ) return 1;
vector<int> v;
mn--;
id = (id-mn)%n+n;
id %= n;
for(int i = id ; i < n ; i++) v.push_back(inputSeq[i]);
for(int i = 0 ; i < id ; i++) v.push_back(inputSeq[i]);
priority_queue<pair<int,int>> pq;
for(int i = 0 ; i < n ; i++){
pq.push({-v[i],i+1});
}
int mx = *max_element(v.begin(),v.end());
if( mx == n ) return 0;
int cur = n+1;
int ti = 0;
while(!pq.empty()){
while(cur <= -pq.top().first){
replacementSeq[ti] = pq.top().second;
ti++;
cur++;
}
pq.pop();
}
return mx-n;
}
int countReplacement(int n, int inputSeq[]){
return 0;
}
int valid(int n,int inputSeq[]){
int mn = INT_MAX;
int id;
map<int,int> cnt;
for(int i = 0 ; i < n ; i++){
cnt[inputSeq[i]]++;
if( cnt[inputSeq[i]] > 1 ) return 0;
}
for(int i = 0 ; i < n ; i++){
if( mn > inputSeq[i] ){
mn = inputSeq[i];
id = i;
}
}
if( mn > n ) return 1;
vector<int> v;
mn--;
id = (id-mn)%n+n;
id %= n;
for(int i = id ; i < n ; i++) v.push_back(inputSeq[i]);
for(int i = 0 ; i < id ; i++) v.push_back(inputSeq[i]);
for(int i = 0 ; i < n ; i++){
if( v[i] <= n && v[i] != i+1 ) return 0;
}
return 1;
}
//~ int main(){
//~ ios_base::sync_with_stdio(false);
//~ cin.tie(0);
//~ cout.tie(0);
//~ cin>>n;
//~ for(int i = 0 ; i < n ; i++){
//~ cin>>inputSeq[i];
//~ }
//~ int replacementSeq[1000];
//~ cout<<replacement(n,inputSeq,replacementSeq)<<"\n";
}
Compilation message
gondola.cpp:91:1: error: expected declaration before '}' token
91 | }
| ^