Submission #217274

# Submission time Handle Problem Language Result Execution time Memory
217274 2020-03-29T10:41:10 Z fedoseevtimofey Chameleon's Love (JOI20_chameleon) C++14
40 / 100
22 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);
      }
    }
  }
  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) {
    cout << "start " << i + 1 << endl;
    for (int j : bad[i]) {
      cout << j + 1 << ' ';
    }
    cout << endl;
    cout << "finish";
    cout << endl;
  }
  cout << endl;
  exit(0);*/
  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);
    }
  }
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 22 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 416 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 416 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 512 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 21 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 22 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -