# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955591 | ono_de206 | Toxic Gene (NOI23_toxic) | C++17 | 5 ms | 508 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "toxic.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
//#define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
void determine_type(int n) {
vector<int> type(n + 1, -1);
int cc = 0;
auto dfs = [&](auto &self, int l, int r) {
vector<int> ask(r - l + 1);
iota(all(ask), l);
cc++;
if(query_sample(ask) == r - l + 1) return;
if(l == r) {
type[l] = 1;
// cout << l << '\n';
} else {
int m = (l + r) / 2;
self(self, l, m);
self(self, m + 1, r);
}
};
int b = 5;
for(int l = 1, r; l <= n; l += b) {
r = min(n, l + b - 1);
dfs(dfs, l, r);
}
// cout << endl;
// cout << " cc here " << cc << endl;
vector<int> non;
int samp;
for(int i = 1; i <= n; i++) {
if(type[i] == -1) non.pb(i);
else samp = i;
}
for(int l = 0, r; l < non.size(); l = r) {
r = min((int)non.size(), l + 7);
vector<int> ask{samp};
for(int j = l; j < r; j++) {
int cnt = (1 << (j - l));
for(int _ = 0; _ < cnt; _++) {
ask.pb(non[j]);
}
}
int ans = query_sample(ask);
for(int j = l; j < r; j++) {
int cnt = (1 << (j - l));
if(ans & cnt) type[non[j]] = 0;
else type[non[j]] = 2;
}
}
string str = "STR";
for(int i = 1; i <= n; i++) {
answer_type(i, str[type[i]]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |