Submission #956119

# Submission time Handle Problem Language Result Execution time Memory
956119 2024-04-01T06:19:22 Z ono_de206 Toxic Gene (NOI23_toxic) C++17
93.25 / 100
22 ms 600 KB
#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;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
void determine_type(int n) {
	vector<int> type(n + 1, 2), sorr, dnow;
	int toxic = 0, samp;
	for(int i = 1; i <= n; i++) {
		dnow.pb(i);
	}
	shuffle(all(dnow), rng);
 
	while(dnow.size()) {
		shuffle(all(dnow), rng);
		vector<int> ask;
		int sz = min((int)dnow.size(), 8);
		for(int i = 0; i < sz; i++) {
			for(int j = 0; j < (1 << i); j++) {
				ask.pb(dnow[i]);
			}
		}
		int ans = query_sample(ask);
		if(ans == ask.size()) {
			for(int i = 0; i < sz; i++) {
				sorr.pb(dnow[0]);
				dnow.erase(dnow.begin());
			}
			continue;
		}
		vector<int> torr;
		for(int i = 0; i < sz; i++) {
			if(ans & (1 << i)) type[dnow[0]] = 0;
			else torr.pb(dnow[0]);
			dnow.erase(dnow.begin());
		}
		int l = 0, r = torr.size() + 1;
		while(r - l > 1) {
			int m = (l + r) / 2;
			ask.clear();
			for(int i = l; i < m; i++) {
				ask.pb(torr[i]);
			}
			int szdn = min((int)sorr.size(), 8);
			for(int i = 0; i < szdn; i++) {
				for(int j = 0; j < (1 << i); j++) {
					ask.pb(sorr[i]);
				}
			}
			ans = query_sample(ask);
			if(ans == ask.size()) {
				l = m;
			} else {
				r = m;
				for(int i = 0; i < szdn; i++) {
					if(ans & (1 << i)) type[sorr[0]] = 0;
					sorr.erase(sorr.begin());
				}
			}
		}
		type[torr[l]] = 1;
		samp = torr[l];
		for(int i = l + 1; i < torr.size(); i++) {
			dnow.pb(torr[i]);
		}
		toxic++;
		if(toxic == 30) {
			for(int x : dnow) {
				sorr.pb(x);
			}
			dnow.clear();
		}
	}
 
	while(sorr.size()) {
		vector<int> ask;
		int sz = min((int)sorr.size(), 8);
		for(int i = 0; i < sz; i++) {
			for(int j = 0; j < (1 << i); j++) {
				ask.pb(sorr[i]);
			}
		}
		ask.pb(samp);
		int ans = query_sample(ask);
		for(int i = 0; i < sz; i++) {
			if(ans & (1 << i)) type[sorr[0]] = 0;
			sorr.erase(sorr.begin());
		}
	}
 
	string str = "STR";
	for(int i = 1; i <= n; i++) {
		answer_type(i, str[type[i]]);
	}
}

Compilation message

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:41:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if(ans == ask.size()) {
      |      ~~~~^~~~~~~~~~~~~
toxic.cpp:68:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |    if(ans == ask.size()) {
      |       ~~~~^~~~~~~~~~~~~
toxic.cpp:80:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |   for(int i = l + 1; i < torr.size(); i++) {
      |                      ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 19 ms 516 KB Output is correct
3 Correct 16 ms 512 KB Output is correct
4 Correct 15 ms 348 KB Output is correct
5 Correct 18 ms 508 KB Output is correct
6 Partially correct 18 ms 348 KB Partially correct
7 Correct 20 ms 348 KB Output is correct
8 Correct 18 ms 516 KB Output is correct
9 Correct 17 ms 348 KB Output is correct
10 Correct 17 ms 348 KB Output is correct
11 Correct 15 ms 512 KB Output is correct
12 Correct 19 ms 348 KB Output is correct
13 Correct 16 ms 344 KB Output is correct
14 Correct 15 ms 344 KB Output is correct
15 Partially correct 18 ms 348 KB Partially correct
16 Correct 22 ms 348 KB Output is correct
17 Partially correct 18 ms 512 KB Partially correct
18 Correct 18 ms 508 KB Output is correct
19 Correct 19 ms 348 KB Output is correct
20 Correct 17 ms 512 KB Output is correct
21 Correct 15 ms 348 KB Output is correct
22 Correct 13 ms 508 KB Output is correct
23 Correct 13 ms 512 KB Output is correct
24 Correct 16 ms 344 KB Output is correct
25 Correct 17 ms 556 KB Output is correct
26 Correct 16 ms 344 KB Output is correct
27 Correct 16 ms 348 KB Output is correct
28 Correct 14 ms 508 KB Output is correct
29 Correct 18 ms 348 KB Output is correct
30 Correct 18 ms 512 KB Output is correct
31 Correct 17 ms 512 KB Output is correct
32 Correct 18 ms 344 KB Output is correct
33 Correct 15 ms 348 KB Output is correct
34 Correct 18 ms 348 KB Output is correct
35 Partially correct 17 ms 348 KB Partially correct
36 Correct 3 ms 600 KB Output is correct