답안 #301510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
301510 2020-09-18T03:32:52 Z qpwoeirut 식물 비교 (IOI20_plants) C++17
0 / 100
4000 ms 23032 KB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

int N;
vector<set<int>> adj;
void init(int k, vector<int> r) {
    N = r.size();
    adj = vector<set<int>>(N, set<int>());
    for (int i=0; i<N; ++i) {
        int u = i, v = (i+1) % N;
        if (r[u] == 0) {
            adj[u].insert(v);
        } else {
            adj[v].insert(u);
        }
    }
}

int compare_plants(int x, int y) {
    vector<bool> visited(N);
    queue<int> q;
    q.push(x);
    visited[x] = true;
    while (q.size() > 0) {
        int cur = q.front(); q.pop();
        for (auto it=adj[cur].begin(); it!=adj[cur].end(); ++it) {
            if (!visited[*it]) {
                if (*it == y) {
                    return 1;
                }
                visited[*it] = true;
                q.push(*it);
            }
        }
    }
    fill(visited.begin(), visited.end(), false);
    q.push(y);
    visited[y] = true;
    while (q.size() > 0) {
        int cur = q.front(); q.pop();
        for (auto it=adj[cur].begin(); it!=adj[cur].end(); ++it) {
            if (!visited[*it]) {
                if (*it == x) {
                    return -1;
                }
                visited[*it] = true;
                q.push(*it);
            }
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 106 ms 3192 KB Output is correct
7 Correct 689 ms 5112 KB Output is correct
8 Correct 627 ms 23032 KB Output is correct
9 Correct 1127 ms 23032 KB Output is correct
10 Execution timed out 4009 ms 23032 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 106 ms 3192 KB Output is correct
7 Correct 689 ms 5112 KB Output is correct
8 Correct 627 ms 23032 KB Output is correct
9 Correct 1127 ms 23032 KB Output is correct
10 Execution timed out 4009 ms 23032 KB Time limit exceeded
11 Halted 0 ms 0 KB -