Submission #1268595

#TimeUsernameProblemLanguageResultExecution timeMemory
1268595IcelastSuper Dango Maker (JOI22_dango3)C++20
7 / 100
733 ms760 KiB
#include "dango3.h" #include <iostream> #include <bits/stdc++.h> #define ll long long using namespace std; const ll maxn = 2*1e5+5, INF = 4e18+9; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rand rd long long rd(long long l, long long h) { return l + rng() % (h - l + 1); } namespace { int variable_example = 1; } // namespace void Solve(int N, int M) { vector<int> p(N*M+1); for(int i = 1; i <= N*M; i++) p[i] = i; shuffle(p.begin()+1, p.end(), rng); vector<int> d(N*M+1, 0); vector<int> has; auto ask = [&](int r) -> int{ vector<int> a; for(int i : has){ a.push_back(i); } for(int i = 1; i <= r; i++){ if(d[p[i]]) continue; a.push_back(p[i]); } if(a.empty()){ cout << "SIU"; exit(0); } return Query(a); }; int last; auto bs = [&]() -> int{ int l = last, r = N*M; while(l < r){ int mid = (l+r)/2; if(ask(mid) > 0){ r = mid; }else{ l = mid+1; } } return l; }; vector<vector<int>> res(N+1); for(int i = 1; i <= N; i++){ last = 1; for(int j = 1; j <= M; j++){ int pos = bs(); last = pos+1; res[i].push_back(p[pos]); d[p[pos]] = 1; } for(int j : res[i]){ has.push_back(j); } } for(int j = 0; j < M; j++){ vector<int> a; for(int i = 1; i <= N; i++){ a.push_back(res[i][j]); // cout << res[i][j] << "s\n"; } Answer(a); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...