Submission #1040352

# Submission time Handle Problem Language Result Execution time Memory
1040352 2024-08-01T01:52:16 Z nightfal Comparing Plants (IOI20_plants) C++14
0 / 100
0 ms 348 KB
#include "plants.h"
#include <cstdio>
#include <cassert>
#include <vector>

static int n, k, q;
static std::vector<int> r;
static std:: vector<int> x;
static std:: vector<int> y;
static std:: vector<int> answer;
static std:: vector<int> inc,dec;
 
void init(int k, std::vector<int> r) {
	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];}      	          
    }
	return;
}
int subtask1(int x, int y) {
	if (x<y) {
      if (y<= dec[x] or x<= inc[y] and inc[y] <= y) return 1;
      else if (y <= inc[x] or x<= dec[y] and dec[y] <= y) return -1;
    }
  	else {
  	  if (y<= inc[x] or x<= dec[y] and dec[y] <= y) return 1;
      else if (y <= dec[x] or x<= inc[y] and inc[y] <= y) return -1;
    }
	return 0;
}
int compare_plants(int x, int y) {
  	if (k==2) return subtask1(x,y);
	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:18:35: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   18 |       for(s=0; s<n; s++) {if (r[s]=0) break;}
plants.cpp: In function 'int subtask1(int, int)':
plants.cpp:27:36: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   27 |       if (y<= dec[x] or x<= inc[y] and inc[y] <= y) return 1;
      |                         ~~~~~~~~~~~^~~~~~~~~~~~~~~
plants.cpp:28:42: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   28 |       else if (y <= inc[x] or x<= dec[y] and dec[y] <= y) return -1;
      |                               ~~~~~~~~~~~^~~~~~~~~~~~~~~
plants.cpp:31:35: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   31 |      if (y<= inc[x] or x<= dec[y] and dec[y] <= y) return 1;
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~
plants.cpp:32:42: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   32 |       else if (y <= dec[x] or x<= inc[y] and inc[y] <= y) return -1;
      |                               ~~~~~~~~~~~^~~~~~~~~~~~~~~
plants.cpp: At global scope:
plants.cpp:6:18: warning: 'q' defined but not used [-Wunused-variable]
    6 | static int n, k, q;
      |                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -