답안 #591959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591959 2022-07-08T09:32:58 Z Jarif_Rahman 카멜레온의 사랑 (JOI20_chameleon) C++17
20 / 100
65 ms 396 KB
#include "chameleon.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

namespace {
    int query(vector<int> v){
        for(int &x: v) x++;
        return Query(v);
    }
    void answer(int a, int b){
        Answer(a+1, b+1);
    }
}

void Solve(int n){
    vector<vector<int>> v(2*n);
    set<pair<int, int>> s;

    for(int i = n; i < 2*n; i++){
        vector<int> sth;
        for(int j = 0; j < n; j++) sth.pb(j);
        while(!sth.empty()){
            auto ss = sth;
            ss.pb(i);
            if(query(ss) == ss.size()) break;

            int l = 0, r = sth.size();
            while(l < r){
                int md = (l+r)/2;
                vector<int> ss(sth.begin(), sth.begin()+md+1);
                ss.pb(i);
                if(query(ss) == ss.size()) l = md+1;
                else r = md;
            }

            v[i].pb(sth[l]);
            v[sth[l]].pb(i);

            sth.erase(sth.begin()+l);
        }
    }

    for(int i = 0; i < 2*n; i++) for(int x: v[i]) s.insert({min(i, x), max(i, x)});

    for(int i = 0; i < 2*n; i++){
        if(v[i].size() < 3) continue;
        int a = v[i][0], b = v[i][1], c = v[i][2];
        int rm = -1;
        if(query({i, a, b}) == 1) rm = c;
        else if(query({i, a, c}) == 1) rm = b;
        else rm = a;
        if(s.find({min(i, rm), max(i, rm)}) != s.end()) s.erase({min(i, rm), max(i, rm)});
    }

    for(auto [a, b]: s) answer(a, b);
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if(query(ss) == ss.size()) break;
      |                ~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp:37:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |                 if(query(ss) == ss.size()) l = md+1;
      |                    ~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 65 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 53 ms 396 KB Output is correct
4 Correct 58 ms 396 KB Output is correct
5 Correct 54 ms 388 KB Output is correct
6 Correct 54 ms 396 KB Output is correct
7 Correct 54 ms 388 KB Output is correct
8 Correct 52 ms 392 KB Output is correct
9 Correct 52 ms 396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 65 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -