Submission #1008958

#TimeUsernameProblemLanguageResultExecution timeMemory
1008958hotboy2703Gondola (IOI14_gondola)C++14
55 / 100
18 ms4652 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; using ll = int; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) int valid(int n, int a[]) { set <ll> s; for (ll i = 0,expected = -n;i < n;i ++,expected=expected+1>n?1:expected+1){ if (s.insert(a[i]).se==0)return 0; if (a[i] > n)continue; if (expected < 0)expected = a[i]; if (expected != a[i])return 0; } return 1; } //---------------------- int replacement(int n, int a[], int ans[]) { ll ptr = 0; vector <ll> b(n); iota(b.begin(),b.end(),1); for (ll i = 0;i < n;i ++){ if (a[i] <= n){ b[i] = a[i]; for (ll j = i + 1;j < n;j ++){ b[j] = b[j-1]+1; if (b[j] > n)b[j] = 1; } for (ll j = i - 1;j >= 0;j--){ b[j] = b[j+1]-1; if (b[j]==0)b[j] = n; } break; } } vector <pll> all; for (ll i = 0;i < n;i ++){ if (a[i] > n){ all.push_back(MP(a[i],b[i])); } } sort(all.begin(),all.end()); ll last = n; for (auto x:all){ last++; ans[ptr++]=x.se; for (ll i = last+1;i<=x.fi;i++)ans[ptr++]=i-1; last = x.fi; } return ptr; } //---------------------- 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...