답안 #941041

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941041 2024-03-08T05:42:29 Z socpite Toxic Gene (NOI23_toxic) C++17
37.7176 / 100
21 ms 596 KB
#include<bits/stdc++.h>
#include"toxic.h"
using namespace std;

mt19937 rng(69420);

int query_sample(vector<int> species);

int h[301];

int shuffled_query(vector<int> speices){
	for(auto &v: speices)v = h[v];
	return query_sample(speices);
}

void shuffled_answer(int x, char c){
	answer_type(h[x], c);
}

void determine_type(int n){
    int l = 1, r = n;
	iota(h+1, h+n+1, 1);
	// shuffle(h+1, h+n+1, rng);
    vector<int> vec(n);
	vector<bool> bad(n+1, 0);
    vector<bool> done(n+1, 0);
    iota(vec.begin(), vec.end(), 1);
    while(l < r){
        int mid = (l+r)>>1;
		int tmp = shuffled_query(vector<int>(vec.begin() + l - 1, vec.begin() + mid));
        if(tmp != mid - l + 1)r = mid;
        else l = mid+1;
    }
    vec.erase(vec.begin() + l - 1);
    shuffled_answer(l, 'T');
	// vector<int> missing;
	int tcnt = 0;
    while(!vec.empty()){
		shuffle(vec.begin(), vec.end(), rng);
        vector<int> sampling;
        vector<int> species;
        vector<int> missing;
        for(int i = 0; i < min<int>(8, vec.size()); i++){
            sampling.push_back(vec[i]);
            for(int _ = 0; _ < (1<<i); _++)species.push_back(vec[i]);
        }
		for(int i = 0; i < sampling.size(); i++)vec.erase(vec.begin());
		bool all_bad = 1;
		for(auto v: sampling)if(!bad[v])all_bad = 0;
		if(all_bad && tcnt == 30){
			for(auto v: sampling)shuffled_answer(v, 'R');	
		}
        int tot1 = shuffled_query(species);
        if(tot1 == species.size()){
            species.push_back(l);
			if(all_bad || tcnt == 30){
				for(auto v: sampling)shuffled_answer(v, 'R');
				continue;
			}
            int tot2 = shuffled_query(species);
            for(int i = 0; i < sampling.size(); i++){
                if((tot1&tot2)&(1<<i))shuffled_answer(sampling[i], 'S');
                else shuffled_answer(sampling[i], 'R');
            }
        }
        else {
			shuffle(missing.begin(), missing.end(), rng);
            for(int i = 0; i < sampling.size(); i++){
                if(tot1&(1<<i)){
                    shuffled_answer(sampling[i], 'S');
                }
                else missing.push_back(sampling[i]);
            }
			int i;
			for(i = 0; i + 1 < missing.size(); i++){
				if(!shuffled_query({missing[i]})){
					shuffled_answer(missing[i], 'T');
					for(int j = i+1; j < missing.size(); j++)vec.push_back(missing[j]);
					break;
				}
				shuffled_answer(missing[i], 'R');
			}
			if(i == missing.size() - 1)shuffled_answer(missing[i], 'T');
        }
    }
}

Compilation message

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i = 0; i < sampling.size(); i++)vec.erase(vec.begin());
      |                  ~~^~~~~~~~~~~~~~~~~
toxic.cpp:54:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         if(tot1 == species.size()){
      |            ~~~~~^~~~~~~~~~~~~~~~~
toxic.cpp:61:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             for(int i = 0; i < sampling.size(); i++){
      |                            ~~^~~~~~~~~~~~~~~~~
toxic.cpp:68:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             for(int i = 0; i < sampling.size(); i++){
      |                            ~~^~~~~~~~~~~~~~~~~
toxic.cpp:75:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |    for(i = 0; i + 1 < missing.size(); i++){
      |               ~~~~~~^~~~~~~~~~~~~~~~
toxic.cpp:78:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |      for(int j = i+1; j < missing.size(); j++)vec.push_back(missing[j]);
      |                       ~~^~~~~~~~~~~~~~~~
toxic.cpp:83:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |    if(i == missing.size() - 1)shuffled_answer(missing[i], 'T');
      |       ~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Partially correct 16 ms 344 KB Partially correct
3 Partially correct 16 ms 348 KB Partially correct
4 Partially correct 15 ms 348 KB Partially correct
5 Partially correct 18 ms 344 KB Partially correct
6 Partially correct 18 ms 536 KB Partially correct
7 Partially correct 19 ms 348 KB Partially correct
8 Partially correct 18 ms 348 KB Partially correct
9 Partially correct 21 ms 520 KB Partially correct
10 Partially correct 17 ms 596 KB Partially correct
11 Partially correct 15 ms 348 KB Partially correct
12 Partially correct 16 ms 348 KB Partially correct
13 Partially correct 16 ms 540 KB Partially correct
14 Partially correct 15 ms 348 KB Partially correct
15 Partially correct 19 ms 348 KB Partially correct
16 Partially correct 17 ms 348 KB Partially correct
17 Partially correct 18 ms 516 KB Partially correct
18 Partially correct 20 ms 348 KB Partially correct
19 Partially correct 18 ms 348 KB Partially correct
20 Partially correct 17 ms 548 KB Partially correct
21 Partially correct 15 ms 344 KB Partially correct
22 Correct 13 ms 348 KB Output is correct
23 Correct 13 ms 348 KB Output is correct
24 Partially correct 15 ms 540 KB Partially correct
25 Partially correct 16 ms 348 KB Partially correct
26 Partially correct 16 ms 540 KB Partially correct
27 Partially correct 15 ms 344 KB Partially correct
28 Partially correct 15 ms 348 KB Partially correct
29 Partially correct 19 ms 344 KB Partially correct
30 Partially correct 18 ms 548 KB Partially correct
31 Partially correct 17 ms 348 KB Partially correct
32 Partially correct 17 ms 348 KB Partially correct
33 Partially correct 15 ms 348 KB Partially correct
34 Partially correct 21 ms 540 KB Partially correct
35 Partially correct 18 ms 540 KB Partially correct
36 Partially correct 3 ms 344 KB Partially correct