답안 #932960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932960 2024-02-24T16:16:29 Z AdamGS 카멜레온의 사랑 (JOI20_chameleon) C++17
100 / 100
47 ms 788 KB
#include "chameleon.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1007;
vector<int>V[LIM];
map<pair<int,int>,int>mp;
int kol[LIM];
void DFS(int x, int k) {
  kol[x]=k;
  for(auto i : V[x]) if(!kol[i]) DFS(i, k^3);
}
int szukaj(vector<int>A, int x) {
  vector<int>X;
  for(auto i : A) X.pb(i+1);
  X.pb(x+1);
  int p=Query(X);
  if(p==X.size()) return -1;
  int po=0, ko=A.size()-1;
  while(po<ko) {
    int sr=(po+ko)/2;
    X.clear();
    rep(i, sr+1) X.pb(A[i]+1);
    X.pb(x+1);
    p=Query(X);
    if(p==X.size()) po=sr+1; else ko=sr;
  }
  return A[po];
}
void dodaj(int a, int b) {
  if(a>b) swap(a, b);
  ++mp[{a, b}];
  if(mp[{a, b}]==2) {
    Answer(a+1, b+1);
  }
}
void Solve(int n) {
  rep(i, 2*n) {
    rep(j, i) kol[j]=0;
    rep(j, i) if(!kol[j]) DFS(j, 1);
    vector<int>A, B;
    rep(j, i) if(kol[j]==1) A.pb(j); else B.pb(j);
    rep(xd, 2) {
      while(true) {
        int p=szukaj(A, i);
        if(p==-1) break;
        vector<int>tmp;
        for(auto i : A) if(i!=p) tmp.pb(i);
        A=tmp;
        V[p].pb(i);
        V[i].pb(p);
      }
      A=B;
    }
  }
  rep(i, 2*n) {
    if(V[i].size()==1) {
      dodaj(i, V[i][0]);
      continue;
    }
    vector<int>X;
    X.pb(i+1);
    X.pb(V[i][0]+1);
    X.pb(V[i][1]+1);
    if(Query(X)==1) {
      dodaj(i, V[i][0]);
      dodaj(i, V[i][1]);
      continue;
    }
    X[1]=V[i][2]+1;
    if(Query(X)==1) {
      dodaj(i, V[i][1]);
      dodaj(i, V[i][2]);
      continue;
    }
    dodaj(i, V[i][0]);
    dodaj(i, V[i][2]);
  }
}

Compilation message

chameleon.cpp: In function 'int szukaj(std::vector<int>, int)':
chameleon.cpp:22:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   if(p==X.size()) return -1;
      |      ~^~~~~~~~~~
chameleon.cpp:30:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if(p==X.size()) po=sr+1; else ko=sr;
      |        ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 18 ms 544 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 18 ms 344 KB Output is correct
6 Correct 18 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 18 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 47 ms 520 KB Output is correct
4 Correct 45 ms 552 KB Output is correct
5 Correct 41 ms 528 KB Output is correct
6 Correct 42 ms 788 KB Output is correct
7 Correct 43 ms 548 KB Output is correct
8 Correct 42 ms 592 KB Output is correct
9 Correct 42 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 18 ms 544 KB Output is correct
4 Correct 18 ms 344 KB Output is correct
5 Correct 18 ms 344 KB Output is correct
6 Correct 18 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 18 ms 344 KB Output is correct
9 Correct 18 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 47 ms 520 KB Output is correct
31 Correct 45 ms 552 KB Output is correct
32 Correct 41 ms 528 KB Output is correct
33 Correct 42 ms 788 KB Output is correct
34 Correct 43 ms 548 KB Output is correct
35 Correct 42 ms 592 KB Output is correct
36 Correct 42 ms 600 KB Output is correct
37 Correct 39 ms 592 KB Output is correct
38 Correct 20 ms 344 KB Output is correct
39 Correct 38 ms 540 KB Output is correct
40 Correct 38 ms 540 KB Output is correct
41 Correct 38 ms 536 KB Output is correct
42 Correct 18 ms 536 KB Output is correct
43 Correct 42 ms 592 KB Output is correct
44 Correct 40 ms 588 KB Output is correct
45 Correct 38 ms 544 KB Output is correct