Submission #794946

# Submission time Handle Problem Language Result Execution time Memory
794946 2023-07-27T04:22:04 Z vjudge1 Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 312 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[0]] == r[R[n-1]])
            R.push_back(R[0]),R.pop_front(), info[i][2] = 1;
        else 
            break;
    info[R[0]][0] = 1;
    info[R[0]][1] = r[R[0]];
    for(int i = 1; i < n; i++) {
        info[R[i]][1] = r[R[i]];
        if(r[R[i]]!=r[R[i-1]]) {
            info[R[i]][0] = ++cnt;
        } else {
            info[R[i]][0] = info[R[i-1]][0];
        }
    }
	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(b)
        swap(x,y);
    int ans = (info[x][1]^info[x][2]^x>y)?1:-1;
    return b^ans;
}

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