Submission #795013

# Submission time Handle Problem Language Result Execution time Memory
795013 2023-07-27T05:12:37 Z boyliguanhan Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 316 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define N 200100
#define n R.size()
int pos[N], cnt;
deque<int> R;
int info[200100][3];
void init2(int k, vector<int> r) {
    R.resize(r.size());
    iota(R.begin(), R.end(), 0);
    for(int i = 0; i < n; i++)
        if(r[R.front()] == r[R.back()])
            R.push_back(R.front()),R.pop_front(), info[i][2] = 1;
        else 
            break;
    info[R.front()][0] = 0;
    info[R.front()][1] = r[R.front()];
    int prev = R.front();
    for(int i = 1; i < n; i++) {
        info[R.front()][1] = r[R.front()];
        if(r[R.front()]!=r[prev]) {
            info[R.front()][0] = ++cnt;
        } else {
            info[R.front()][0] = info[prev][0];
        }
        prev = R.front();
        R.pop_front();
    }
	return;
}
void init(int k, vector<int> r) {
    init2(k,r);
}
int compare_plants(int x, int y) {
    bool a = info[x][0] == info[y?y-1:n-1][0], b = info[x?x-1:n-1][0]==info[y][0];
	if(!a&&!b)
        return 0;
    if(!a&&b)
        swap(x,y);
    int ans = (info[x][1]^info[x][2]^x>y);
    return ((!a&&b)^ans?1:-1);
}

Compilation message

plants.cpp: In function 'void init2(int, std::vector<int>)':
plants.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i = 0; i < n; i++)
      |                      ^
plants.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 1; i < n; i++) {
      |                      ^
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:41:39: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   41 |     int ans = (info[x][1]^info[x][2]^x>y);
      |                                      ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -