답안 #944932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944932 2024-03-13T08:21:36 Z gelastropod 카멜레온의 사랑 (JOI20_chameleon) C++14
0 / 100
15 ms 596 KB
#include "chameleon.h"
#include <vector>
#include <bits/stdc++.h>

using namespace std;

namespace {

int variable_example = 1;

}  // namespace

void Solve(int N) {
    vector<vector<int>> adjlist(2 * N, vector<int>());
    for (int i = 0; i < 2 * N; i++)
    {
        for (int j = 0; j < 2 * N; j++)
        {
            if (i != j)
            {
                vector<int> a = {i + 1, j + 1};
                int b = Query(a);
                if (b == 1)
                {
                    adjlist[i].push_back(j);
                }
            }
        }
    }
    vector<bool> done(2 * N, false);
    for (int i = 0; i < 2 * N; i++)
    {
        if (adjlist[i].size() == 1 && !done[i] && !done[adjlist[i][0]])
        {
            done[i] = true;
            done[adjlist[i][0]] = true;
            Answer(i + 1, adjlist[i][0] + 1);
        }
        else if (!done[i] && !done[adjlist[i][0]])
        {
            vector<int> a = {i + 1, adjlist[i][0] + 1, adjlist[i][1] + 1};
            int b = Query(a);
            if (b == 1)
            {
                adjlist[i].erase(adjlist[i].begin() + 2);
                continue;
            }
            a = {i + 1, adjlist[i][0] + 1, adjlist[i][2] + 1};
            b = Query(a);
            if (b == 1)
            {
                adjlist[i].erase(adjlist[i].begin() + 1);
                continue;
            }
            a = {i + 1, adjlist[i][2] + 1, adjlist[i][1] + 1};
            b = Query(a);
            if (b == 1)
            {
                adjlist[i].erase(adjlist[i].begin());
            }
        }
    }
    for (int i = 0; i < 2 * N; i++)
    {
        if (adjlist[i].size() != 1)
        {
            if (adjlist[adjlist[i][0]].size() != 1 && adjlist[adjlist[i][1]].size() != 1)
            {
                if ((adjlist[adjlist[i][0]][0] == i || adjlist[adjlist[i][0]][1] == i) && !done[i] && !done[adjlist[i][0]])
                {
                    done[i] = true;
                    done[adjlist[i][0]] = true;
                    Answer(i + 1, adjlist[i][0] + 1);
                }
                else if ((adjlist[adjlist[i][1]][0] == i || adjlist[adjlist[i][1]][1] == i) && !done[i] && !done[adjlist[i][1]])
                {
                    done[i] = true;
                    done[adjlist[i][1]] = true;
                    Answer(i + 1, adjlist[i][1] + 1);
                }
            }
        }
    }
}

Compilation message

chameleon.cpp:9:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    9 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 15 ms 472 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 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 344 KB Wrong Answer [7]
10 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 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Incorrect 0 ms 344 KB Wrong Answer [7]
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Incorrect 15 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 Incorrect 15 ms 472 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -