Submission #448100

# Submission time Handle Problem Language Result Execution time Memory
448100 2021-07-29T01:48:37 Z jhnah917 Chameleon's Love (JOI20_chameleon) C++14
40 / 100
30 ms 1328 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
    int N, Match[1010];
    bool Love[1010][1010];
    vector<int> G[1010];
}  // namespace

bool HasEdge(int u, int v){
    return Query({ u, v }) == 1;
}

int Like(int v){
    int a = G[v][0], b = G[v][1], c = G[v][2];
    if(Query({ v, b, c }) == 1) return a;
    if(Query({ v, a, c }) == 1) return b;
    return c;
}

void Init(){
    memset(Match, -1, sizeof Match);
    memset(Love, 0, sizeof Love);
    for(int i=0; i<1010; i++) G[i].clear();
}

void Solve(int n){
    N = n + n; Init();
    for(int i=1; i<=N; i++){
        for(int j=1; j<i; j++){
            if(HasEdge(i, j)) G[i].push_back(j), G[j].push_back(i);
        }
    }
    for(int i=1; i<=N; i++){
        if(G[i].size() == 1){
            Match[i] = G[i][0];
            Match[G[i][0]] = i;
            continue;
        }
        auto j = Like(i);
        Love[i][j] = Love[j][i] = true;
    }
    for(int i=1; i<=N; i++){
        if(Match[i] != -1) continue;
        for(auto j : G[i]) if(!Love[i][j]) Match[i] = j;
    }
    for(int i=1; i<=N; i++) if(i < Match[i]) Answer(i, Match[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1224 KB Output is correct
2 Correct 1 ms 1224 KB Output is correct
3 Incorrect 30 ms 1224 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1224 KB Output is correct
2 Correct 1 ms 1224 KB Output is correct
3 Correct 1 ms 1224 KB Output is correct
4 Correct 1 ms 1224 KB Output is correct
5 Correct 1 ms 1224 KB Output is correct
6 Correct 1 ms 1224 KB Output is correct
7 Correct 1 ms 1224 KB Output is correct
8 Correct 1 ms 1224 KB Output is correct
9 Correct 1 ms 1224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1224 KB Output is correct
2 Correct 1 ms 1224 KB Output is correct
3 Correct 1 ms 1224 KB Output is correct
4 Correct 1 ms 1224 KB Output is correct
5 Correct 1 ms 1224 KB Output is correct
6 Correct 1 ms 1224 KB Output is correct
7 Correct 1 ms 1224 KB Output is correct
8 Correct 1 ms 1224 KB Output is correct
9 Correct 1 ms 1224 KB Output is correct
10 Correct 2 ms 1224 KB Output is correct
11 Correct 2 ms 1224 KB Output is correct
12 Correct 2 ms 1224 KB Output is correct
13 Correct 2 ms 1224 KB Output is correct
14 Correct 3 ms 1224 KB Output is correct
15 Correct 3 ms 1224 KB Output is correct
16 Correct 3 ms 1224 KB Output is correct
17 Correct 3 ms 1224 KB Output is correct
18 Correct 2 ms 1224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1224 KB Output is correct
2 Correct 1 ms 1224 KB Output is correct
3 Incorrect 25 ms 1328 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1224 KB Output is correct
2 Correct 1 ms 1224 KB Output is correct
3 Incorrect 30 ms 1224 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -