Submission #365499

# Submission time Handle Problem Language Result Execution time Memory
365499 2021-02-11T18:24:22 Z valerikk Chameleon's Love (JOI20_chameleon) C++17
0 / 100
1 ms 364 KB
#include "chameleon.h"
#include <bits/stdc++.h> 
using namespace std;

int query(vector<int> p) {
    return Query(p);
}

void answer(int a, int b) {
    Answer(a, b);
}

const int N = 505;

vector<int> g[2 * N];
int color[2 * N];
vector<int> component[2];

void dfs(int u) {
    component[color[u]].push_back(u);
    for (int v : g[u]) {
        if (color[v] == -1) {
            color[v] = color[u] ^ 1;
            dfs(v);
        }
    }   
}

int my_query(int i, int j) {
    auto p = component[color[i]];
    p.push_back(j);
    return query(p);
}

void solve(int n) {
    vector<pair<int, int>> pairs;
    for (int i = 1; i <= 2 * n; i++) {
        for (int j = 1; j < i; j++) {
            if (query(vector<int>{i, j}) == 1) 
                pairs.emplace_back(i, j);
        }
    }
    
    for (auto [i, j] : pairs) {
        g[i].push_back(j);
        g[j].push_back(i);
    }

    for (int i = 1; i <= 2 * n; i++) 
        color[i] = -1;
    color[1] = 0;
    dfs(1);

    for (auto [i, j] : pairs) {
        int ij = my_query(i, j), ji = my_query(j, i);
        if (ij == n && ji == n || (ij + ji == 2 * n - 1)) 
            answer(i, j);
    }

}

void Solve(int N) {
    solve(N);
}



Compilation message

chameleon.cpp: In function 'void solve(int)':
chameleon.cpp:56:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   56 |         if (ij == n && ji == n || (ij + ji == 2 * n - 1))
      |             ~~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -