Submission #555983

# Submission time Handle Problem Language Result Execution time Memory
555983 2022-05-02T06:16:19 Z AriaH Super Dango Maker (JOI22_dango3) C++17
22 / 100
1180 ms 596 KB
/* Im the best and i work like that */

#pragma GCC optimize("Ofast")
#include "dango3.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

#define F first
#define S second
#define all(x) x.begin(),x.end()
#define Mp make_pair
#define point complex
#define endl '\n'
#define SZ(x) (int)x.size()
#define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file_io freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define mashtali return cout << "Hello, World!", 0;

const int N = 1e4 + 10;
const int LOG = 20;
const ll mod = 1e9 + 7;
const ll inf = 8e18;
const double pi = acos(-1);
const ld eps = 1e-18;
const ld one = 1.;

ll pw(ll a, ll b, ll M, ll ret = 1) { if(a == 0) return 0; a %= M; while(b) { ret = (b & 1? ret * a % M : ret), a = a * a % M, b >>= 1; } return ret % M; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, id[N], B[N];

inline int ask()
{
  ///printf("asking : \n");
  vector < int > vec;
  for(int i = 1; i <= n * m; i ++)
  {
    if(B[i]) vec.push_back(id[i]);
  }
  /*for(auto x : vec)
  {
    printf("%d ", x);
  }
  */
  int ret = (SZ(vec) < n? 0 : Query(vec));
  ///printf("ans : %d\n", ret);
  return ret;
}

void _Answer(vector < int > vec)
{
  vector < int > ret;
  for(auto x : vec) ret.push_back(id[x]);
  Answer(ret);
}

vector < int > EXT(vector < int > vec)
{
  if(SZ(vec) < n) return vec;
  memset(B, 0, sizeof B);
  vector < int > ret, out;
  for(int i = 0; i < SZ(vec); i ++)
  {
    B[vec[i]] = 1;
  }
  for(int i = 0; i < SZ(vec); i ++)
  {
    B[vec[i]] = 0;
    if(ask())
    {
      ret.push_back(vec[i]);
    }
    else
    {
      out.push_back(vec[i]);
      B[vec[i]] = 1;
    }
  }
  memset(B, 0, sizeof B);
  for(auto x : ret) B[x] = 1;
  _Answer(out);
  return ret;
}

void Solve(int _n, int _m)
{
  n = _n;
  m = _m;
  for(int i = 1; i <= n * m; i ++)
  {
    id[i] = i;
  }
  shuffle(id + 1, id + n * m + 1, rng);
  for(int i = 1; i <= n * m; i ++)
  {
    printf("%d ", id[i]);
  }
  printf("\n");
  int ptr = 1;
  vector < int > vec;
  int q = m;
  while(q --)
  {
    while(ask() == 0)
    {
      ///printf("ptr = %d\n", ptr);
      B[ptr] = 1;
      vec.push_back(ptr);
      ptr ++;
    }
    if(q == 0)
    {
      _Answer(vec);
      return;
    }
    vec = EXT(vec);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 468 KB Output is correct
2 Correct 14 ms 340 KB Output is correct
3 Correct 14 ms 424 KB Output is correct
4 Correct 13 ms 420 KB Output is correct
5 Correct 11 ms 340 KB Output is correct
6 Correct 15 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 348 ms 472 KB Output is correct
2 Correct 351 ms 596 KB Output is correct
3 Correct 356 ms 588 KB Output is correct
4 Correct 378 ms 476 KB Output is correct
5 Correct 342 ms 464 KB Output is correct
6 Correct 328 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1180 ms 540 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -