답안 #616960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
616960 2022-08-01T07:55:15 Z 조영욱(#8505) 카멜레온의 사랑 (JOI20_chameleon) C++17
0 / 100
1 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);
}

int f(int ind,int l,int r) {
    if (l>r) {
        return -1;
    }
    while (l<r) {
        int mid=(l+r)/2;
        vector<int> vec;
        vec.push_back(ind);
        for(int i=l;i<=mid;i++) {
            vec.push_back(i);
        }
        int got=Query(vec);
        if (got==mid-l+2) {
            l=mid+1;
        }
        else {
            r=mid;
        }
    }
    vector<int> vec;
    vec.push_back(ind);
    vec.push_back(l);
    if (Query(vec)==1) {
        return l;
    }
    else {
        return -1;
    }
}

}  // namespace

void Solve(int N) {
    n=N;
    for(int i=1;i<=n;i++) {
        int one;
        int two=-1;
        int three=-1;
        one=f(i,n+1,n*2);
        two=f(i,one+1,n*2);
        if (two!=-1) {
            three=f(i,two+1,n*2);
        }
        arr[i][one]=true;
        deg[i]=1;
        if (two!=-1) {
            arr[i][two]=true;
            arr[i][three]=true;
            deg[i]=3;
        }
    }
    for(int i=1;i<=n;i++) {
        if (deg[i]!=1) {
            continue;
        }
        used[i]=true;
        for(int j=n+1;j<=n*2;j++) {
            if (arr[i][j]) {
                ret[i]=j;
                ret[j]=i;
            }
        }
    }
    for(int now=1;now<=n;now++) {
        if (used[now]) {
            continue;
        }
        vector<int> v;
        for(int j=n+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) {
            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:104:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |         for(int i=0;i<v.size();i++){
      |                     ~^~~~~~~~~
chameleon.cpp:105:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |             for(int j=i+1;j<v.size();j++) {
      |                           ~^~~~~~~~~
chameleon.cpp: At global scope:
chameleon.cpp:15:5: warning: 'int {anonymous}::f2(int, int)' defined but not used [-Wunused-function]
   15 | int f2(int x,int y) {
      |     ^~
chameleon.cpp:7:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    7 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 [1]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 1 ms 464 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 1 ms 464 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 368 KB Output is correct
2 Incorrect 1 ms 208 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 [1]
4 Halted 0 ms 0 KB -