답안 #217292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217292 2020-03-29T11:17:59 Z fedoseevtimofey 카멜레온의 사랑 (JOI20_chameleon) C++14
0 / 100
28 ms 512 KB
#include "chameleon.h"
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

void Solve(int n) {
  vector <vector <int>> g(2 * n);
  /*for (int i = 0; i < 2 * n; ++i) {
    for (int j = i + 1; j < 2 * n; ++j) {
      int x = Query({i + 1, j + 1});
      if (x == 1) {
        g[i].push_back(j);
        g[j].push_back(i);
      }
    }
  }*/
  function <void(int, vector <int>)> rec = [&] (int v, vector <int> a) {
    if (a.size() == 1) {
      if (Query({v + 1, a[0] + 1}) == 1) {
        g[v].push_back(a[0]);
        g[a[0]].push_back(v);
      }
    } else {
      int m = a.size() / 2;
      vector <int> b, c;
      for (int i = 0; i < m; ++i) b.push_back(a[i] + 1);
      for (int i = m; i < (int)a.size(); ++i) c.push_back(a[i] + 1);
      b.push_back(v + 1);
      c.push_back(v + 1);
      if (Query(b) != (int)b.size() + 1) {
        b.clear();
        for (int i = 0; i < m; ++i) b.push_back(a[i]);
        rec(v, b);
      }
      if (Query(c) != (int)c.size() + 1) {
        c.clear();
        for (int i = m; i < (int)a.size(); ++i) c.push_back(a[i]);
        rec(v, c);
      }
    }
  };

  
  vector <int> a;
  for (int i = n; i < 2 * n; ++i) a.push_back(i);
  for (int i = 0; i < n; ++i) rec(i, a);
  vector <int> who(2 * n, -1);
  vector <set <int>> bad(2 * n);
  for (int i = 0; i < 2 * n; ++i) {
    if (g[i].size() == 1) {
      who[i] = g[i][0];
      who[g[i][0]] = i;
    } else if (g[i].size() == 3) {
      for (int j = 0; j < 3; ++j) {
        vector <int> p = {i + 1};
        for (int k = 0; k < 3; ++k) {
          if (k != j) p.push_back(g[i][k] + 1);
        }
        if (Query(p) == 1) {
          bad[i].insert(g[i][j]);
          bad[g[i][j]].insert(i);
        }
      }
    } else {
      assert(false);
    }
  }
  for (int i = 0; i < 2 * n; ++i) {
    if (who[i] == -1) {
      for (int j = 0; j < (int)g[i].size(); ++j) {
        if (!bad[i].count(g[i][j])) {
          who[i] = g[i][j];
        }
      }
    }
  }

  for (int i = 0; i < 2 * n; ++i) {
    if (who[i] > i) {
      Answer(i + 1, who[i] + 1);
    }
  }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 28 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 28 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 28 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -