Submission #772920

# Submission time Handle Problem Language Result Execution time Memory
772920 2023-07-04T12:56:10 Z fve5 Comparing Plants (IOI20_plants) C++17
0 / 100
4000 ms 18112 KB
#include <bits/stdc++.h>
using namespace std;

#define MAXN 200'000

vector<int> adj[MAXN];

void init(int k, vector<int> r) {
    for (int i = 0; i < r.size(); i++) {
        if (r[i] == k - 1) {
            for (int j = 1; j < k; j++) {
                adj[(i + j) % r.size()].push_back(i);
            }
        }
        if (r[i] == 0) {
            for (int j = 1; j < k; j++) {
                adj[i].push_back((i + j) % r.size());
            }
        }
    }
}

int compare_plants(int x, int y) {
    {
        set<int> visited;
        stack<int> q;
        q.push(x);
        while (!q.empty()) {
            auto curr = q.top(); q.pop();
            if (visited.count(curr)) continue;
            if (curr == y) return 1;
            visited.insert(curr);

            for (auto n: adj[curr]) {
                q.push(n);
            }
        }
    }
    {
        set<int> visited;
        stack<int> q;
        q.push(y);
        while (!q.empty()) {
            auto curr = q.top(); q.pop();
            if (visited.count(curr)) continue;
            if (curr == x) return -1;
            visited.insert(curr);

            for (auto n: adj[curr]) {
                q.push(n);
            }
        }
    }
    return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 77 ms 8708 KB Output is correct
7 Correct 1894 ms 10672 KB Output is correct
8 Correct 247 ms 17688 KB Output is correct
9 Correct 1899 ms 17972 KB Output is correct
10 Execution timed out 4077 ms 18112 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4996 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Incorrect 2 ms 4948 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4996 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Incorrect 2 ms 4948 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4988 KB Output is correct
2 Incorrect 2 ms 4948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Incorrect 2 ms 4948 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 5000 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Incorrect 2 ms 4948 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 77 ms 8708 KB Output is correct
7 Correct 1894 ms 10672 KB Output is correct
8 Correct 247 ms 17688 KB Output is correct
9 Correct 1899 ms 17972 KB Output is correct
10 Execution timed out 4077 ms 18112 KB Time limit exceeded
11 Halted 0 ms 0 KB -