답안 #269707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
269707 2020-08-17T09:02:02 Z mhy908 카멜레온의 사랑 (JOI20_chameleon) C++14
24 / 100
67 ms 504 KB
#include "chameleon.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(x.begin(), x.end())
#define press(x) x.erase(unique(x.begin(), x.end()), x.end())
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=2e18;
const int inf=1e9;

int n, siz[1010];
vector<int> link[1010];
bool ch[1010];

vector<int> vc[2];
int arr[1010];

void Solve(int N){
    n=N;
    for(int i=1; i<=2*n; i++){
        vector<int> qu=vc[1];
        qu.eb(i);
        if(Query(qu)==qu.size()){
            vc[1].eb(i);
            arr[i]=1;
        }
        else vc[0].eb(i);
    }
    for(int i=1; i<=2*n; i++){
        vector<int> nvc;
        for(auto j:vc[1-arr[i]]){
            if(j<i)nvc.eb(j);
        }
        while(1){
            vector<int> qu=nvc;
            qu.eb(i);
            if(Query(qu)==qu.size())break;
            int l=0, r=nvc.size()-1;
            while(l<r) {
                int mid=(l+r)/2+1;
                vector<int> qu2;
                for(int j=mid; j<nvc.size(); j++)qu2.eb(nvc[j]);
                qu2.eb(i);
                if(Query(qu2)==qu2.size())r=mid-1;
                else l=mid;
            }
            link[i].eb(nvc[l]);
            link[nvc[l]].eb(i);
            while(nvc.size()>l)nvc.pop_back();
        }
    }
    for(int i=1; i<=2*n; i++){
        if(link[i].size()<=2)continue;
        assert(link[i].size()==3);
        vector<int> qu;
        for(int j=0; j<3; j++){
            qu.clear();
            qu.eb(i);
            for(auto k:link[i]){
                if(link[i][j]==k)continue;
                qu.eb(k);
            }
            if(Query(qu)==1){
                swap(link[i][j], link[i][2]);
                link[i].pop_back();
                break;
            }
        }
    }
    for(int i=1; i<=2*n; i++){
        if(ch[i])continue;
        for(auto j:link[i]){
            bool flg=false;
            for(auto k:link[j]){
                if(k==i)flg=true;
            }
            if(flg){
                Answer(i, j);
                ch[i]=ch[j]=true;
                break;
            }
        }
    }
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         if(Query(qu)==qu.size()){
      |            ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:45:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             if(Query(qu)==qu.size())break;
      |                ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:50:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |                 for(int j=mid; j<nvc.size(); j++)qu2.eb(nvc[j]);
      |                                ~^~~~~~~~~~~
chameleon.cpp:52:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                 if(Query(qu2)==qu2.size())r=mid-1;
      |                    ~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp:57:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |             while(nvc.size()>l)nvc.pop_back();
      |                   ~~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 31 ms 384 KB Output is correct
4 Correct 30 ms 384 KB Output is correct
5 Correct 33 ms 384 KB Output is correct
6 Correct 30 ms 384 KB Output is correct
7 Correct 34 ms 384 KB Output is correct
8 Correct 31 ms 384 KB Output is correct
9 Correct 32 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Wrong Answer [6]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Wrong Answer [6]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 62 ms 384 KB Output is correct
4 Correct 62 ms 384 KB Output is correct
5 Correct 67 ms 444 KB Output is correct
6 Correct 62 ms 384 KB Output is correct
7 Correct 65 ms 504 KB Output is correct
8 Correct 63 ms 384 KB Output is correct
9 Correct 63 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 31 ms 384 KB Output is correct
4 Correct 30 ms 384 KB Output is correct
5 Correct 33 ms 384 KB Output is correct
6 Correct 30 ms 384 KB Output is correct
7 Correct 34 ms 384 KB Output is correct
8 Correct 31 ms 384 KB Output is correct
9 Correct 32 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Incorrect 1 ms 384 KB Wrong Answer [6]
14 Halted 0 ms 0 KB -