답안 #215872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
215872 2020-03-26T11:56:46 Z BThero 카멜레온의 사랑 (JOI20_chameleon) C++17
40 / 100
28 ms 512 KB
#define DBG 1
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#include "chameleon.h"
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) if (DBG) cerr << #x << " = " << x << endl;

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pii;

//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

namespace {
    const int MAXN = 1005;
    vector<int> adj[MAXN];
    int partner[MAXN], loves[MAXN], n;    
}

void Solve(int _n) {
    n = _n;
    
    for (int i = 1; i <= 2 * n; ++i) {
        for (int j = 1; j <= 2 * n; ++j) {
            if (i != j && Query({i, j}) == 1) {
                adj[i].pb(j);
            }
        }
    }
    
    for (int i = 1; i <= 2 * n; ++i) {
        assert(adj[i].size() == 1 || adj[i].size() == 3);
        
        if (adj[i].size() == 1) {
            partner[i] = adj[i][0];
            continue;
        }
        
        while (Query({i, adj[i][0], adj[i][1]}) != 1) {
            rotate(adj[i].begin(), adj[i].begin() + 1, adj[i].end());
        }
        
        loves[i] = adj[i][2];
    }
    
    for (int i = 1; i <= 2 * n; ++i) {
        if (loves[adj[i][0]] == i) {
            partner[i] = adj[i][1];
        }
        else {
            partner[i] = adj[i][0];
        }
    }
    
    for (int i = 1; i <= 2 * n; ++i) {
        if (i < partner[i]) {
            Answer(i, partner[i]);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 28 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 416 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 7 ms 384 KB Output is correct
14 Correct 7 ms 308 KB Output is correct
15 Correct 7 ms 384 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 8 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 28 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 28 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -