Submission #1040515

# Submission time Handle Problem Language Result Execution time Memory
1040515 2024-08-01T06:46:35 Z nightfal Comparing Plants (IOI20_plants) C++14
5 / 100
41 ms 8804 KB
#include "plants.h"
static std:: vector<int> inc,dec;
 
// void print(std::vector<int> &v) {for(int elem: v) std::cout << elem << " "; std::cout << std::endl;}
void init(int k, std::vector<int> r) {
    int n = r.size();
	if(k==2) {
      inc.resize(n); dec.resize(n);
      for(int i=0; i<n; i++) {inc[i] = dec[i] = i;}
      int s;
      for(s=0; s<n; s++) {if (r[s]==0) break;}
      for(int i=s-1+n; i>=s+1; i--) {if (r[i%n]) inc[i%n] = inc[(i+1)%n];}
      for(s=0; s<n; s++) {if (r[s]) break;}
      for(int i=s-1+n; i>=s+1; i--) {if (r[i%n]==0) dec[i%n] = dec[(i+1)%n];}      	          
    //   print(inc); print(dec);
    }
	return;
}
int subtask1(int x, int y) {
      if (dec[x] < x or y <= dec[x] or x <= inc[y] and inc[y] < y) return 1;
      else if (inc[x] < x or y <= inc[x] or x <= dec[y] and dec[y] < y) return -1;
	return 0;
}
int compare_plants(int x, int y) {
  	return subtask1(x,y);
	return 0;
}

Compilation message

plants.cpp: In function 'int subtask1(int, int)':
plants.cpp:20:52: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   20 |       if (dec[x] < x or y <= dec[x] or x <= inc[y] and inc[y] < y) return 1;
      |                                        ~~~~~~~~~~~~^~~~~~~~~~~~~~
plants.cpp:21:57: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   21 |       else if (inc[x] < x or y <= inc[x] or x <= dec[y] and dec[y] < y) return -1;
      |                                             ~~~~~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 25 ms 4168 KB Output is correct
7 Correct 29 ms 5456 KB Output is correct
8 Correct 40 ms 8788 KB Output is correct
9 Correct 39 ms 8780 KB Output is correct
10 Correct 40 ms 8764 KB Output is correct
11 Correct 41 ms 8780 KB Output is correct
12 Correct 41 ms 8780 KB Output is correct
13 Correct 40 ms 8804 KB Output is correct
14 Correct 38 ms 8784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 0 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 0 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 0 ms 420 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 0 ms 348 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 0 ms 348 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 25 ms 4168 KB Output is correct
7 Correct 29 ms 5456 KB Output is correct
8 Correct 40 ms 8788 KB Output is correct
9 Correct 39 ms 8780 KB Output is correct
10 Correct 40 ms 8764 KB Output is correct
11 Correct 41 ms 8780 KB Output is correct
12 Correct 41 ms 8780 KB Output is correct
13 Correct 40 ms 8804 KB Output is correct
14 Correct 38 ms 8784 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Runtime error 0 ms 348 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -