#include "gondola.h"
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
ll mod=99824LL;
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
int valid(int n, int inputSeq[])
{
ll N=(ll) n;
vector<ll> s; REP(i,0,N) {s.pb((ll) inputSeq[i]);}
vector<ll> copy = s; sort(whole(copy));
REP(i,0,N-1) {if(copy[i]==copy[i+1]) {return 0;}}
REP(i,0,N) {if(s[i]>N) {s[i]=-1;} else {s[i]--;}}
ll fi=-1;
REP(i,0,N) {if(s[i]!=-1) {fi=i; break;}}
if(fi==-1) {return 1;}
REP(i,0,N)
{
if(s[i]==-1) {continue;}
if(((s[i]-i)-(s[fi]-fi))%N!=0) {return 0;}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int r[])
{
ll N =(ll) n; vector<ll> s; REP(i,0,N) {s.pb((ll) gondolaSeq[i]);}
REP(i,0,N)
{
if(s[i]<=N)
{
ll shift = (s[i]-1LL-i)%N; //shift to the right
vector<ll> copy_s; REP(j,0,N) {copy_s.pb(s[(j-shift+N)%N]);}
s=copy_s; break;
}
}
ll max_ind = (ll) (max_element(whole(s))-s.begin());
ll R = s[max_ind]-N;
unordered_map<ll,ll> m;
REP(i,0,N) {m[s[i]]=i;}
ll last = max_ind+1;
REP(i,0,R)
{
ll val = N+i+1;
unordered_map<ll,ll>::iterator it = m.find(val);
if(it==m.end()) {r[i]=last; last=val;}
else if(m[val]!=max_ind) {r[i]=m[val]+1;}
else {r[i]=last; last=val;}
}
return R;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
9 ms |
1148 KB |
Output is correct |
7 |
Correct |
22 ms |
2164 KB |
Output is correct |
8 |
Correct |
16 ms |
1908 KB |
Output is correct |
9 |
Correct |
8 ms |
892 KB |
Output is correct |
10 |
Correct |
21 ms |
2036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
9 ms |
1148 KB |
Output is correct |
7 |
Correct |
21 ms |
2164 KB |
Output is correct |
8 |
Correct |
15 ms |
1908 KB |
Output is correct |
9 |
Correct |
6 ms |
892 KB |
Output is correct |
10 |
Correct |
20 ms |
2036 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
0 ms |
256 KB |
Output is correct |
13 |
Correct |
9 ms |
1148 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
23 ms |
2156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
25 ms |
5000 KB |
Output is correct |
12 |
Correct |
24 ms |
5556 KB |
Output is correct |
13 |
Correct |
20 ms |
2664 KB |
Output is correct |
14 |
Correct |
31 ms |
5000 KB |
Output is correct |
15 |
Correct |
25 ms |
2328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |