Submission #388020

# Submission time Handle Problem Language Result Execution time Memory
388020 2021-04-09T18:21:35 Z Supersonic Comparing Plants (IOI20_plants) C++17
5 / 100
758 ms 11352 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int a[400001];int b[400001];int n;
void init(int k, std::vector<int> r) {
	if(k==2){
		n=r.size();
		for(int i=0;i<n;i++)r.push_back(r[i]);
		for(int i=0;i<2*n;i++)b[i]=r[i];
		a[0]=0;
		for(int i=1;i<2*n;i++){if(r[i]==r[i-1])a[i]=a[i-1];else a[i]=a[i-1]+1;}
	}
	return;
}

int compare_plants(int x, int y) {
	//cerr<<x<<' '<<y<<endl;
	if(x>y)y+=n;y--;
	if(a[x]==a[y]){
		//cerr<<b.size()<<endl;
		if(b[x]==0)return 1;
		else return -1;
	}
	cerr<<x<<' '<<y<<endl;
	y++;y%=n;if(y>x)x+=n;x--;

	if(a[x]==a[y]){
		//cerr<<b.size()<<endl;
		if(b[y]==0)return -1;
		else return 1;
	}
	return 0;
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:18:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   18 |  if(x>y)y+=n;y--;
      |  ^~
plants.cpp:18:14: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   18 |  if(x>y)y+=n;y--;
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 723 ms 4536 KB Output is correct
7 Correct 699 ms 6764 KB Output is correct
8 Correct 733 ms 11212 KB Output is correct
9 Correct 753 ms 11220 KB Output is correct
10 Correct 758 ms 11352 KB Output is correct
11 Correct 727 ms 11276 KB Output is correct
12 Correct 713 ms 11120 KB Output is correct
13 Correct 98 ms 10960 KB Output is correct
14 Correct 96 ms 10956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 723 ms 4536 KB Output is correct
7 Correct 699 ms 6764 KB Output is correct
8 Correct 733 ms 11212 KB Output is correct
9 Correct 753 ms 11220 KB Output is correct
10 Correct 758 ms 11352 KB Output is correct
11 Correct 727 ms 11276 KB Output is correct
12 Correct 713 ms 11120 KB Output is correct
13 Correct 98 ms 10960 KB Output is correct
14 Correct 96 ms 10956 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Incorrect 1 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -