답안 #722490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722490 2023-04-12T06:44:26 Z alvingogo 카멜레온의 사랑 (JOI20_chameleon) C++14
4 / 100
56 ms 340 KB
#include "chameleon.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;

namespace {

int variable_example = 1;
    int n;
}  // namespace

bool find(int x,int y){
    vector<int> g;
    for(int i=1;i<=n;i++){
        if(i==x || i==y){
            continue;
        }
        g.push_back(i);
    }
    int z=Query(g);
    return z==(n/2-1);
}
mt19937 rnd(time(NULL));
void Solve(int N) {
    n=2*N;
    vector<int> tt(n);
    iota(tt.begin(),tt.end(),1);
    while(tt.size()>2){
        shuffle(tt.begin(),tt.end(),rnd);
        vector<int> s,t;
        for(auto h:tt){
            if(!s.size()){
                s.push_back(h);
                continue;
            }
            s.push_back(h);
            if(Query(s)==s.size()){
                continue;
            }
            s.pop_back();
            cerr << h << "\n";
            int l=0,r=((int)s.size())-1;
            while(r>l){
                int m=(l+r)/2;
                vector<int> tmp;
                for(int i=0;i<=m;i++){
                    tmp.push_back(s[i]);
                }
                tmp.push_back(h);
                if(Query(tmp)<=(int)tmp.size()-1){
                    r=m;
                }
                else{
                    l=m+1;
                }
            }
            cerr << s[l] << " " << h << "\n";
            if(find(s[l],h)){
                Answer(s[l],h);
                swap(s[l],s.back());
                s.pop_back();
            }
            else{
                t.push_back(h);
            }
        }
        s.insert(s.end(),t.begin(),t.end());
        tt.swap(s);
    }
    if(tt.size()){
        Answer(tt[0],tt[1]);
    }
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:37:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             if(Query(s)==s.size()){
      |                ~~~~~~~~^~~~~~~~~~
chameleon.cpp: At global scope:
chameleon.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    8 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 25 ms 328 KB Output is correct
4 Correct 23 ms 336 KB Output is correct
5 Correct 20 ms 336 KB Output is correct
6 Correct 23 ms 340 KB Output is correct
7 Correct 24 ms 332 KB Output is correct
8 Correct 23 ms 340 KB Output is correct
9 Correct 23 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 56 ms 324 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 56 ms 324 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 46 ms 332 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 25 ms 328 KB Output is correct
4 Correct 23 ms 336 KB Output is correct
5 Correct 20 ms 336 KB Output is correct
6 Correct 23 ms 340 KB Output is correct
7 Correct 24 ms 332 KB Output is correct
8 Correct 23 ms 340 KB Output is correct
9 Correct 23 ms 332 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Incorrect 56 ms 324 KB Wrong Answer [3]
12 Halted 0 ms 0 KB -