제출 #941015

#제출 시각아이디문제언어결과실행 시간메모리
941015socpiteToxic Gene (NOI23_toxic)C++17
58.15 / 100
21 ms600 KiB
#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> 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; 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]); } int tot1 = shuffled_query(species); if(tot1 == species.size()){ species.push_back(l); 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'); vec.erase(find(vec.begin(), vec.end(), sampling[i])); } } else { for(int i = 0; i < sampling.size(); i++){ if(tot1&(1<<i)){ shuffled_answer(sampling[i], 'S'); vec.erase(find(vec.begin(), vec.end(), sampling[i])); } else missing.push_back(sampling[i]); } int ql = 0, r = missing.size()-1; while(ql < r){ int mid = (ql+r)>>1; if(!shuffled_query(vector<int>(missing.begin(), missing.begin() + mid + 1)))r = mid; else ql = mid+1; } for(int i = 0; i <= ql; i++){ if(i < ql)shuffled_answer(missing[i], 'R'); else shuffled_answer(missing[i], 'T'); vec.erase(find(vec.begin(), vec.end(), missing[i])); } } } }

컴파일 시 표준 에러 (stderr) 메시지

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         if(tot1 == species.size()){
      |            ~~~~~^~~~~~~~~~~~~~~~~
toxic.cpp:49:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             for(int i = 0; i < sampling.size(); i++){
      |                            ~~^~~~~~~~~~~~~~~~~
toxic.cpp:56:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             for(int i = 0; i < sampling.size(); i++){
      |                            ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...