Submission #259933

# Submission time Handle Problem Language Result Execution time Memory
259933 2020-08-08T20:09:00 Z srj Gondola (IOI14_gondola) C++14
55 / 100
96 ms 9976 KB
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;

int valid(int n, int inputSeq[])
{
	map<int,int> pos;
  for(int i =0;i<n;i++){
  		if(pos.find(inputSeq[i])!=pos.end())
  			return 0;	
  			pos[inputSeq[i]] = i;
  }
  int sortSeq[n];
  memcpy(sortSeq,inputSeq,sizeof(sortSeq));
  sort(sortSeq,sortSeq+n);
  if(sortSeq[0]>n)
  	return 1;
  int smallval = sortSeq[0];
  int cur = pos[sortSeq[0]];
  for(int i =0;i<n;i++){
  	if(inputSeq[(cur+i)%n]!=smallval+i && inputSeq[(cur+i)%n]<=n){
  		// cout << smallval << endl;
  		// cout << i << endl;
  		return 0;
  	}
  }
  return 1;
}

//----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
	map<int,int> pos;
  for(int i =0;i<n;i++){
  		if(pos.find(gondolaSeq[i])!=pos.end())
  			return 0;	
  			pos[gondolaSeq[i]] = i;
  }
  int sortSeq[n];
  map<int,int> what;
  memcpy(sortSeq,gondolaSeq,sizeof(sortSeq));
  sort(sortSeq,sortSeq+n);
  int pos1 = 0;
  if(sortSeq[0]<=n){
  	pos1 = (n+pos[sortSeq[0]]-sortSeq[0]+1)%n;
  }
  what[pos1] = 1;
  pos[1] = pos1;
  for(int i =2;i<=n;i++){
  	pos[i] = (n+pos1+i-1)%n;
  	what[pos[i]] = i;
  }
  int nxt = n+1;
  int ans = sortSeq[n-1] - nxt+1;
  int j =0;
  for(int i =0;i<n;i++){
  	if(sortSeq[i]>n){
  		int where = pos[sortSeq[i]];
  		int prev = what[where];
  		while(prev!=sortSeq[i]){
  			replacementSeq[j] = prev;
  			prev=nxt;
  			nxt++;
  			j++;
  		}
  		what[where] = prev;	
  	}
  }
  return ans;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:9:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(pos.find(inputSeq[i])!=pos.end())
     ^~
gondola.cpp:11:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      pos[inputSeq[i]] = i;
      ^~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:36:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(pos.find(gondolaSeq[i])!=pos.end())
     ^~
gondola.cpp:38:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      pos[gondolaSeq[i]] = i;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 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 19 ms 2560 KB Output is correct
7 Correct 14 ms 1152 KB Output is correct
8 Correct 38 ms 4608 KB Output is correct
9 Correct 11 ms 1664 KB Output is correct
10 Correct 45 ms 5368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 19 ms 2560 KB Output is correct
7 Correct 14 ms 1152 KB Output is correct
8 Correct 44 ms 4728 KB Output is correct
9 Correct 11 ms 1664 KB Output is correct
10 Correct 52 ms 5368 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 24 ms 2432 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 60 ms 5624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 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
11 Correct 73 ms 8776 KB Output is correct
12 Correct 96 ms 9976 KB Output is correct
13 Correct 61 ms 6140 KB Output is correct
14 Correct 68 ms 8824 KB Output is correct
15 Correct 46 ms 4728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 288 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -