답안 #1000320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000320 2024-06-17T08:37:48 Z Unforgettablepl 카멜레온의 사랑 (JOI20_chameleon) C++17
0 / 100
24 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
 
int Query(const std::vector<int> &p);
void Answer(int a, int b);

void Solve(int N) {
    int n = N;
    vector<vector<int>> adj(2*n+1);
    set<pair<int,int>> edges;
    for(int i=1;i<=n;i++){
        // Find all edges which correspond to 
        vector<int> msuspects(n);iota(msuspects.begin(),msuspects.end(),n+1);
        while(true){
            auto base = Query(msuspects);
            msuspects.emplace_back(i);
            if(Query(msuspects)>base)break;
            msuspects.erase(--msuspects.end());
            auto suspects = msuspects;
            while(suspects.size()>1){
                int mid = suspects.size()/2;
                vector<int> left,right;
                for(int i=0;i<mid;i++)left.emplace_back(suspects[i]);
                for(int i=mid;i<suspects.size();i++)right.emplace_back(suspects[i]);
                auto b = Query(left);
                left.emplace_back(i);
                if(Query(left)>b)suspects=right;
                else {
                    left.erase(--left.end());
                    suspects = left;
                }
            }
            msuspects.erase(lower_bound(msuspects.begin(),msuspects.end(),suspects[0]));
            edges.insert({i,suspects[0]});
            adj[i].emplace_back(suspects[0]);
            adj[suspects[0]].emplace_back(i);
        }
    }
    for(int i=1;i<=2*n;i++){
        if(adj[i].size()==1)continue;
        assert(adj[i].size()==3);
        if(Query({i,adj[i][0],adj[i][1]})==1)edges.erase({min(i,adj[i][2]),max(i,adj[i][2])});
        else if(Query({i,adj[i][0],adj[i][2]})==1)edges.erase({min(i,adj[i][1]),max(i,adj[i][1])});
        else edges.erase({min(i,adj[i][0]),max(i,adj[i][0])});
    }
    for(auto[a,b]:edges)Answer(a,b);
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:24:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                 for(int i=mid;i<suspects.size();i++)right.emplace_back(suspects[i]);
      |                               ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 9 ms 600 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 24 ms 344 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Runtime error 9 ms 600 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -