답안 #995386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995386 2024-06-09T02:13:05 Z 12345678 카멜레온의 사랑 (JOI20_chameleon) C++17
0 / 100
56 ms 556 KB
#include "chameleon.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=1e3+5;

int vs[nx], a, b, n, used[nx], cnt;
vector<int> d[nx];
set<int> s[nx];

void search(int idx)
{
    if (idx<=n) a=n+1, b=2*n;
    else a=1, b=n;
    while (1)
    {
        vector<int> qrs;
        for (int i=a; i<=b; i++) if (!used[i]) qrs.push_back(i);
        qrs.push_back(idx);
        if (Query(qrs)==qrs.size()) break;
        int l=a, r=b;
        while (l<r)
        {
            int md=(l+r)/2;
            vector<int> tmp;
            tmp.push_back(idx);
            for (int i=a; i<=md; i++) if (!used[i]) tmp.push_back(i);
            if (Query(tmp)<tmp.size()) r=md;
            else l=md+1;
        }
        d[idx].push_back(l);
        d[l].push_back(idx);
        used[l]=1;
    }
    for (auto x:d[idx]) used[x]=0;
}

void Solve(int N) {
    n=N;
    for (int i=1; i<=N; i++) search(i);
    for (int i=1; i<=2*N; i++)
    {
        if (vs[i]) continue;
        if (d[i].size()==1)
        {
            Answer(i, d[i][0]);
            vs[i]=vs[d[i][0]]=1;
            continue;
        }
        for (auto x:d[i])
        {
            for (auto y:d[x])
            {
                if (y!=i&&Query(vector<int> {i, x, y})==1) s[i].insert(x);
            }
        }
    }
    for (int i=1; i<=2*N; i++)
    {
        if (vs[i]) continue;
        for (auto x:s[i]) if (s[x].find(i)!=s[x].end()) vs[i]=vs[x]=1, Answer(i, x);
    }
}

Compilation message

chameleon.cpp: In function 'void search(int)':
chameleon.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         if (Query(qrs)==qrs.size()) break;
      |             ~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             if (Query(tmp)<tmp.size()) r=md;
      |                 ~~~~~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 56 ms 540 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 35 ms 556 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 Incorrect 56 ms 540 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -