Submission #423736

# Submission time Handle Problem Language Result Execution time Memory
423736 2021-06-11T12:09:08 Z tqbfjotld Chameleon's Love (JOI20_chameleon) C++14
40 / 100
3 ms 456 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int p[505];
int inv[505];
vector<int> adjl[505];

}

void Solve(int N) {

    for (int x = 1; x<=2*N; x++){
        for (int y = x+1; y<=2*N; y++){
            int res = Query({x,y});
            if (res==1){
                adjl[x].push_back(y);
                adjl[y].push_back(x);
            }
        }
    }
    for (int x = 1; x<=2*N; x++){
        if (adjl[x].size()==3){
            int res1 = Query({x,adjl[x][0],adjl[x][1]});
            int res2 = Query({x,adjl[x][1],adjl[x][2]});
            int res3 = Query({x,adjl[x][0],adjl[x][2]});
            if (res1==1){
                p[x] = adjl[x][2];
            }
            else if (res2==1){
                p[x] = adjl[x][0];
            }
            else{
                p[x] = adjl[x][1];
            }
            inv[p[x]] = x;
        }
    }
    for (int x = 1; x<=2*N; x++){
        if (adjl[x].size()<3){
            if (x<adjl[x][0]){
                Answer(x,adjl[x][0]);
            }
        }
        else{
            int other = -1;
            for (auto y : adjl[x]){
                if (y==p[x]) continue;
                if (y==inv[x]) continue;
                other = y;
            }
            if (x<other){
                Answer(x,other);
            }
        }
    }
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:28:17: warning: unused variable 'res3' [-Wunused-variable]
   28 |             int res3 = Query({x,adjl[x][0],adjl[x][2]});
      |                 ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Runtime error 3 ms 456 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 2 ms 200 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 2 ms 276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Runtime error 2 ms 456 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Runtime error 3 ms 456 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -