Submission #616769

# Submission time Handle Problem Language Result Execution time Memory
616769 2022-08-01T06:41:04 Z 조영욱(#8505) Chameleon's Love (JOI20_chameleon) C++17
0 / 100
11 ms 464 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int variable_example = 1;
int n;
bool arr[101][101];
int deg[101];
bool used[101];
int ret[101];
int cnt[101][101];

int f2(int x,int y) {
    vector<int> v;
    v.push_back(x);
    v.push_back(y);
    return Query(v);
}

int f3(int x,int y,int z) {
    vector<int> v;
    v.push_back(x);
    v.push_back(y);
    v.push_back(z);
    return Query(v);
}

}  // namespace

void Solve(int N) {
    n=N;
    for(int i=1;i<=2*n;i++) {
        for(int j=i+1;j<=2*n;j++){
            if (f2(i,j)==1) {
                arr[i][j]=1;
                arr[j][i]=1;
                deg[i]++;
                deg[j]++;
                //printf("%d %d\n",i,j);
            }
        }
    }
    queue<int> q;
    for(int i=1;i<=n*2;i++) {
        if (deg[i]!=1) {
            continue;
        }
        for(int j=1;j<=n*2;j++) {
            if (arr[i][j]==1) {
                used[i]=true;
                used[j]=true;
                ret[i]=j;
                ret[j]=i;
            }
        }
    }
    for(int now=1;now<=n*2;now++) {
        if (used[now]) {
            continue;
        }
        vector<int> v;
        for(int j=1;j<=n*2;j++) {
            if (arr[now][j]) {
                v.push_back(j);
            }
        }
        assert(v.size()==3);
        for(int i=0;i<v.size();i++){
            for(int j=i+1;j<v.size();j++) {
                int one=v[i];
                int two=v[j];
                if (f3(now,one,two)==1) {
                    cnt[now][one]++;
                    cnt[one][now]++;
                    cnt[now][two]++;
                    cnt[two][now]++;
                }
            }
        }
    }
    for(int i=1;i<=n;i++) {
        if (ret[i]!=0&&i<ret[i]) {
            Answer(i,ret[i]);
        }
    }
    for(int i=1;i<=n*2;i++) {
        for(int j=i+1;j<=n*2;j++) {
            if (cnt[i][j]==2) {
                Answer(i,j);
            }
        }
    }
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:70:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         for(int i=0;i<v.size();i++){
      |                     ~^~~~~~~~~
chameleon.cpp:71:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |             for(int j=i+1;j<v.size();j++) {
      |                           ~^~~~~~~~~
chameleon.cpp: At global scope:
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 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Runtime error 11 ms 464 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Runtime error 8 ms 464 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Runtime error 11 ms 464 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -