QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357407#403. Memory2AMongus2137100 ✓1ms4068kbC++201.6kb2024-03-18 21:04:082024-03-18 21:04:10

Judging History

你现在查看的是最新测评结果

  • [2024-03-18 21:04:10]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:4068kb
  • [2024-03-18 21:04:08]
  • 提交

answer

#include <bits/stdc++.h>
#include "Memory2_lib.h"

using namespace std;
using pii = pair<int, int>;
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define len(x) (int)x.size()

vector<vector<int>> cache;
int n;

int myFlip(int a, int b)
{
  if (a > b)
    swap(a, b);
  if (a == b)
  {
    cerr << "źle";
    exit(true);
  }
  if (cache[a][b] == 0)
  {
    cache[a][b] = Flip(a, b) + 1;
    return cache[a][b] - 1;
  }
  return cache[a][b] - 1;
}

mt19937 ran(2137);

void subsolve(vector<int> div)
{
  // shuffle(all(div), ran);
  // for (int i = 0; i < len(div); i++)
  //   cout << div[i] << " ";
  // cout << "\n";
  if (len(div) == 2)
  {
    Answer(div[0], div[1], myFlip(div[0], div[1]));
    return;
  }

  vector<vector<int>> w(n);
  for (int i = 1; i < len(div); i++)
  {
    w[myFlip(div[0], div[i])].push_back(div[i]);
    // cout << A[div[0]] << " " << A[div[i]] << " ";
    // cout << P[A[div[0]]] << " " << P[A[div[i]]] << " ";
    // cout << div[0] << " " << div[i] << " ";
    // cout << myFlip(div[0], div[i]) << " ";
  }
  // cout << "\n";
  vector<int> p1;
  for (int i = 0; i < n; i++)
  {
    if (len(w[i]) && len(w[i]) != 2)
    {
      p1 = w[i];
      p1.push_back(div[0]);
    }
    else if (len(w[i]))
    {
      Answer(w[i][0], w[i][1], i);
    }
  }
  // cout << most << "\n";
  if (len(p1))
    subsolve(p1);
}

void Solve(int p_T, int p_N)
{
  n = p_N;
  cache.assign(p_N << 1, vector<int>(p_N << 1));
  vector<int> a;
  for (int i = 0; i < p_N << 1; i++)
  {
    a.push_back(i);
  }
  subsolve(a);
}

/*
1 3 10000
0 1 2
1 0 2 0 1 2

*/

Details

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 4028kb

Test #2:

score: 0
Accepted
time: 1ms
memory: 4044kb

Test #3:

score: 0
Accepted
time: 1ms
memory: 3772kb

Test #4:

score: 0
Accepted
time: 0ms
memory: 4064kb

Test #5:

score: 0
Accepted
time: 0ms
memory: 3764kb

Test #6:

score: 0
Accepted
time: 1ms
memory: 3720kb

Test #7:

score: 0
Accepted
time: 1ms
memory: 3864kb

Test #8:

score: 0
Accepted
time: 0ms
memory: 3808kb

Subtask #2:

score: 50
Accepted

Test #9:

score: 50
Accepted
time: 1ms
memory: 4016kb

Test #10:

score: 0
Accepted
time: 0ms
memory: 3800kb

Test #11:

score: 0
Accepted
time: 0ms
memory: 3756kb

Test #12:

score: 0
Accepted
time: 0ms
memory: 3772kb

Test #13:

score: 0
Accepted
time: 1ms
memory: 3860kb

Test #14:

score: 0
Accepted
time: 0ms
memory: 4012kb

Test #15:

score: 0
Accepted
time: 1ms
memory: 3712kb

Test #16:

score: 0
Accepted
time: 0ms
memory: 3820kb

Test #17:

score: 0
Accepted
time: 0ms
memory: 3768kb

Test #18:

score: 0
Accepted
time: 0ms
memory: 4044kb

Subtask #3:

score: 40
Accepted

Test #19:

score: 40
Accepted
time: 1ms
memory: 3772kb

Test #20:

score: 0
Accepted
time: 0ms
memory: 3820kb

Test #21:

score: 0
Accepted
time: 0ms
memory: 3748kb

Test #22:

score: 0
Accepted
time: 0ms
memory: 3776kb

Test #23:

score: 0
Accepted
time: 1ms
memory: 4068kb

Test #24:

score: 0
Accepted
time: 1ms
memory: 3828kb

Test #25:

score: 0
Accepted
time: 0ms
memory: 3776kb

Test #26:

score: 0
Accepted
time: 1ms
memory: 3780kb

Test #27:

score: 0
Accepted
time: 0ms
memory: 4008kb

Test #28:

score: 0
Accepted
time: 1ms
memory: 3784kb

Extra Test:

score: 0
Extra Test Passed