Submission #73292

# Submission time Handle Problem Language Result Execution time Memory
73292 2018-08-28T06:49:04 Z TuGSGeReL Gondola (IOI14_gondola) C++14
25 / 100
109 ms 5660 KB
#include "gondola.h"
#include<bits/stdc++.h>
#define ll int
#define mp make_pair
#define pub push_back
#define pob pop_back
#define ss second
#define ff first
#define ext exit(0)
using namespace std;
ll i,j,z=0,st;
vector<ll> vc,vv;
vector<pair<ll,ll> >v;
map<ll,ll>m;
int valid(int n, int inputSeq[])
{
	for(i=0;i<n;i++){
		if(m[inputSeq[i]]==1) return 0;
		m[inputSeq[i]]++;
	}
	for(i=0;i<n;i++){
		if(inputSeq[i]<n){
			st=(i-inputSeq[i]+1+n)%n;
			for(i=st;i<n;i++) vv.pub(inputSeq[i]);
			for(i=0;i<st;i++) vv.pub(inputSeq[i]);
			for(i=0;i<n;i++){
				if(vv[i]>n) continue;
				if(vv[i]!=i+1) return 0;
			}
			return 1;
		}
	}
	return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
	for(i=0;i<n;i++){
		if(gondolaSeq[i]<=n){
			st=(i-gondolaSeq[i]+1+n)%n;
		}
	}
	for(i=0;i<n;i++){
		if(gondolaSeq[i]>n)v.pub(mp(gondolaSeq[i],(i-st+1+n)%n));
	}
	sort(v.begin(),v.end());
	if(v.size()==0) {
		return 0;
	}
	while(1){
		if(v.size()==1){
			while(v[0].ff>v[0].ss && v[0].ff>n){
				if(v[0].ff-1>n)vc.pub(v[0].ff-1);
				else vc.pub(v[0].ss);
				v[0].ff--;
			}
			break;
		}
		if(v.back().ff==v[v.size()-2].ff+1){
			vc.pub(v.back().ss);
			v.pob();
		}
		else {
			vc.pub(v.back().ff-1);
			v.back().ff--;
			if(v.back().ff==v.back().ss) v.pob();
		}
	}
	reverse(vc.begin(),vc.end());
	for(i=0;i<vc.size();i++) replacementSeq[i]=vc[i];
	return vc.size();
}
int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:68:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<vc.size();i++) replacementSeq[i]=vc[i];
          ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 3 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 568 KB Output is correct
2 Correct 3 ms 568 KB Output is correct
3 Correct 3 ms 568 KB Output is correct
4 Correct 4 ms 568 KB Output is correct
5 Correct 3 ms 576 KB Output is correct
6 Correct 25 ms 2896 KB Output is correct
7 Correct 19 ms 2896 KB Output is correct
8 Correct 46 ms 4816 KB Output is correct
9 Correct 15 ms 4816 KB Output is correct
10 Correct 62 ms 5420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5420 KB Output is correct
2 Correct 2 ms 5420 KB Output is correct
3 Correct 3 ms 5420 KB Output is correct
4 Correct 4 ms 5420 KB Output is correct
5 Correct 2 ms 5420 KB Output is correct
6 Correct 27 ms 5420 KB Output is correct
7 Correct 23 ms 5420 KB Output is correct
8 Correct 46 ms 5420 KB Output is correct
9 Correct 15 ms 5420 KB Output is correct
10 Correct 51 ms 5484 KB Output is correct
11 Correct 3 ms 5484 KB Output is correct
12 Correct 3 ms 5484 KB Output is correct
13 Correct 38 ms 5484 KB Output is correct
14 Correct 4 ms 5484 KB Output is correct
15 Correct 109 ms 5660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5660 KB Output is correct
2 Correct 3 ms 5660 KB Output is correct
3 Correct 3 ms 5660 KB Output is correct
4 Correct 2 ms 5660 KB Output is correct
5 Correct 3 ms 5660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5660 KB Output is correct
2 Correct 3 ms 5660 KB Output is correct
3 Correct 3 ms 5660 KB Output is correct
4 Correct 4 ms 5660 KB Output is correct
5 Correct 2 ms 5660 KB Output is correct
6 Incorrect 3 ms 5660 KB Integer 0 violates the range [1, 5]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5660 KB Output is correct
2 Correct 3 ms 5660 KB Output is correct
3 Correct 3 ms 5660 KB Output is correct
4 Correct 4 ms 5660 KB Output is correct
5 Correct 3 ms 5660 KB Output is correct
6 Incorrect 2 ms 5660 KB Integer 0 violates the range [1, 5]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5660 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5660 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5660 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5660 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -