Submission #1289268

#TimeUsernameProblemLanguageResultExecution timeMemory
1289268__ugur__Chameleon's Love (JOI20_chameleon)C++20
40 / 100
24 ms2904 KiB
#include "chameleon.h"
#include <vector>
#include <bitset>
#include <iostream>
#include <algorithm>
#include <map>


using namespace std;


void Solve(int N) {
  
  //cout << Query({1, 3, 4, 7}) << '\n';
  //cout << Query({1, 2, 3, 4, 5, 6, 7, 8}) << '\n';
  //cout << Query({3, 4, 5, 6, 7, 8}) << '\n';
  //cout << Query({2, 3, 4, 5, 6, 8}) << '\n';
  //cout << Query({2, 3, 4, 5, 6, 7}) << '\n';
  //cout << Query({2, 3, 4, 5, 7, 8}) << '\n';
  //cout << Query({2, 3, 4, 5, 7}) << '\n';

  bitset<1001> found;
  vector<int> counts(2*N+1, 3);
  map<vector<int>, int> pre_calc;
  vector<int> search_order;
  for(int i=2*N; i>0; i--)
    search_order.push_back(i);
  while(search_order.size()) {
    int i = search_order.back();
    search_order.pop_back();
    vector<int> tests;
    if(found[i])
      continue;
    for(int j=2*N; j>0; j--) {
      if(found[j] || i == j)
        continue;
      if(pre_calc[{i, j}] == 0)
        pre_calc[{i, j}] = Query({i, j});
      if(pre_calc[{i, j}] == 1) {
        tests.push_back(j);
        counts[j]--;
        search_order.push_back(j);
      }
      if(tests.size() == counts[i])
        break;
    }

    vector<int> check_same[counts[i]];
    for(int j=1; j<=2*N; j++) {
      if(i == j)
        continue;
      for(int k=0; k<counts[i]; k++) {
        if(tests[k] != j)
          check_same[k].push_back(j); 
      }
    }
    vector<int> results;
    for(int k=0; k<counts[i]; k++) {

      if(pre_calc[check_same[k]] == 0)
        pre_calc[check_same[k]] = Query(check_same[k]);
      results.push_back(pre_calc[check_same[k]]);
    }
    int same = min_element(results.begin(), results.end()) - results.begin();
    same = tests[same];
    found[i] = 1;
    found[same] = 1;
    counts[same] = 0;
    counts[i] = 0;
    Answer(i, same);
  }
  
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...