Submission #799818

# Submission time Handle Problem Language Result Execution time Memory
799818 2023-08-01T05:18:32 Z 이동현(#10084) Chameleon's Love (JOI20_chameleon) C++17
0 / 100
3000 ms 336 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int variable_example = 1;

}  // namespace

vector<int> way[1004];
int chk[1004];

void Solve(int n) {
    for(int i = 1; i <= n * 2; ++i){
        for(int j = i + 1; j <= n * 2; ++j){
            if(i == j){
                continue;
            }

            int rv = Query({i, j});
            if(rv == 1){
                way[i].push_back(j);
                way[j].push_back(i);
            }
        }
    }

    auto del = [&](int x, int y)->void{
        for(int i = 0; i < (int)way[x].size(); ++i){
            if(way[x][i] == y){
                swap(way[x][i], way[x].back());
                way[x].pop_back();
                return;
            }
        }
        assert(0);
    };

    while(true){
        int ed = 1;
        for(int i = 1; i <= n * 2; ++i){
            if((int)way[i].size() < 3){
                continue;
            }

            ed = 0;
            assert((int)way[i].size() == 3);
            for(int j = 0; j < 3; ++j){
                vector<int> ask = {i};
                for(int x = 0; x < 3; ++x){
                    if(j != x){
                        ask.push_back(way[i][x]);
                    }
                }

                int rv = Query(ask);
                if(rv == 1){
                    del(way[i][j], i);
                    del(i, way[i][j]);

                    break;
                }
            }

            assert((int)way[i].size() == 2);
        }

        if(ed) break;
    }

    vector<vector<int>> ans;
    while((int)ans.size() < n){
        for(int i = 1; i <= n * 2; ++i){
            if(chk[i] || (int)way[i].size() > 1) continue;

            assert((int)way[i].size() == 1);

            int nxt = way[i][0];
            chk[i] = chk[nxt] = 1;
            ans.push_back({i, nxt});

            for(auto&j:way[nxt]){
                del(j, nxt);
            }
            way[nxt].clear();
            way[i].clear();
        }
    }

    for(auto&i:ans){
        Answer(i[0], i[1]);
    }
}

Compilation message

chameleon.cpp:7:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    7 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Incorrect 14 ms 336 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Execution timed out 3055 ms 336 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Execution timed out 3055 ms 336 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Execution timed out 3059 ms 208 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Incorrect 14 ms 336 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -