# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
69635 |
2018-08-21T10:24:04 Z |
MANcity |
Gondola (IOI14_gondola) |
C++14 |
|
21 ms |
1516 KB |
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<cstring>
#include<vector>
#include "gondola.h"
using namespace std;
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define for0(i,n) for(int i=0;i<=(int)n;i++)
#define forn(i,n) for(int i=n;i>=1;i--)
#define fo(i,x,y) for(int i=x;i<=(int)y;i++)
#define fr(i,x,y) for(int i=x;i>=(int)y;i--)
#define pb push_back
#define mp make_pair
#define LL long long
const LL Mod=1000*1000*1000+7;
int num[250012];
int valid(int n, int inputSeq[])
{
for0(i,n-1)
num[inputSeq[i]]++;
for1(i,250002)
if(num[i]>=2)
{
return 0;
}
for0(i,n-1)
{
if(inputSeq[i]<=n)
{
int N=inputSeq[i];
fo(j,i+1,n-1)
{
N++;
if(N>n)
N-=n;
if(inputSeq[j]<=n && inputSeq[j]!=N)
return 0;
}
fo(j,0,i-1)
{
N++;
if(N>n)
N-=n;
if(inputSeq[j]<=n && inputSeq[j]!=N)
return 0;
}
return 1;
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
vector<pair<int,int> > V;
int u=0;
for0(i,n-1)
{
if(gondolaSeq[i]<=n)
{
u=1;
int N=gondolaSeq[i];
V.push_back({gondolaSeq[i],N});
fo(j,i+1,n-1)
{
N++;
if(N>n)
N-=n;
V.push_back({gondolaSeq[j],N});
}
fo(j,0,i-1)
{
N++;
if(N>n)
N-=n;
V.push_back({gondolaSeq[j],N});
}
}
}
if(u==0)
{
gondolaSeq[0]=1;
for0(i,n-1)
{
if(gondolaSeq[i]<=n)
{
u=1;
int N=gondolaSeq[i];
V.push_back({gondolaSeq[i],N});
fo(j,i+1,n-1)
{
N++;
if(N>n)
N-=n;
V.push_back({gondolaSeq[j],N});
}
fo(j,0,i-1)
{
N++;
if(N>n)
N-=n;
V.push_back({gondolaSeq[j],N});
}
}
}
}
sort(V.begin(),V.end());
int q=n+1;
int num=-1;
for0(i,V.size()-1)
{
if(V[i].first!=V[i].second)
{
num++;
replacementSeq[num]=V[i].second;
q++;
fo(j,q-1,V[i].first-1)
{
num++;
replacementSeq[num]=j;
}
q=V[i].first+1;
}
}
return (num+1);
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
/*
4 5
8 12 2 10 11
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
436 KB |
Output is correct |
4 |
Correct |
2 ms |
436 KB |
Output is correct |
5 |
Correct |
3 ms |
520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
520 KB |
Output is correct |
2 |
Correct |
3 ms |
536 KB |
Output is correct |
3 |
Correct |
3 ms |
536 KB |
Output is correct |
4 |
Correct |
3 ms |
536 KB |
Output is correct |
5 |
Correct |
3 ms |
580 KB |
Output is correct |
6 |
Correct |
8 ms |
868 KB |
Output is correct |
7 |
Correct |
16 ms |
1252 KB |
Output is correct |
8 |
Correct |
17 ms |
1252 KB |
Output is correct |
9 |
Correct |
5 ms |
1252 KB |
Output is correct |
10 |
Correct |
21 ms |
1252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1252 KB |
Output is correct |
2 |
Correct |
3 ms |
1252 KB |
Output is correct |
3 |
Correct |
3 ms |
1252 KB |
Output is correct |
4 |
Correct |
3 ms |
1252 KB |
Output is correct |
5 |
Correct |
2 ms |
1252 KB |
Output is correct |
6 |
Correct |
8 ms |
1252 KB |
Output is correct |
7 |
Correct |
16 ms |
1260 KB |
Output is correct |
8 |
Correct |
12 ms |
1260 KB |
Output is correct |
9 |
Correct |
6 ms |
1260 KB |
Output is correct |
10 |
Correct |
15 ms |
1260 KB |
Output is correct |
11 |
Correct |
2 ms |
1260 KB |
Output is correct |
12 |
Correct |
3 ms |
1260 KB |
Output is correct |
13 |
Correct |
8 ms |
1516 KB |
Output is correct |
14 |
Correct |
2 ms |
1516 KB |
Output is correct |
15 |
Correct |
18 ms |
1516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1516 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1516 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1516 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1516 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |