제출 #547717

#제출 시각아이디문제언어결과실행 시간메모리
547717LucaDantas버섯 세기 (IOI20_mushrooms)C++17
컴파일 에러
0 ms0 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; constexpr int repeticoes = 80; int qtd_min = 180; vector<int> color[2]; int count_mushrooms(int N) { qtd_min = min(qtd_min, N-1); int cnt[2]{}; color[0] = {0}; vector<int> unknown(N-1); iota(unknown.begin(), unknown.end(), 1); while(unknown.size()) { int usar = color[1].size() > color[0].size(); // escolho o grupo que tem mais gente pra usar int sz = color[usar].size(); if(sz == 2) { for(; (max(color[0].size(), color[1].size()) < 3 || min(color[0].size(), color[1].size()) < 2) && color[0].size() + color[1].size() < qtd_min && unknown.size() > 2;) { vector<int> qr; for(int i = 0; i < 2; i++, unknown.pop_back()) qr.push_back(color[usar][i]), qr.push_back(unknown.back()); int resp = use_machine(qr); color[usar ^ (resp&1)].push_back(qr.back()); resp >>= 1; color[usar ^ (resp&1)].push_back(qr[1]); } /* usar = color[1].size() > color[0].size(); // escolho o grupo que tem mais gente pra usar sz = color[usar].size(); // for(int sla = 0; sla < repeticoes && unknown.size() >= 5; sla++) { for(; color[0].size() + color[1].size() < qtd_min && unknown.size() >= 5;) { vector<int> qr; for(int i = 0; i < 3; i++, unknown.pop_back()) qr.push_back(color[usar][i]), qr.push_back(unknown.back()); int resp = use_machine(qr); color[usar ^ (resp&1)].push_back(qr.back()); qr.pop_back(), qr.pop_back(); resp >>= 1; if(resp&1) { // os dois são diferentes int x1 = qr[1], x2 = qr[3]; int uk1 = unknown.back(); unknown.pop_back(); int uk2 = unknown.back(); unknown.pop_back(); qr.clear(); qr = {color[usar^1][0], x1, color[usar^1][1], color[usar][0], x2, color[usar][1], uk1, color[usar][2], uk2}; int resp = use_machine(qr); resp--; // removo a ligacao obrigatoria entre color[usar^1][1] e color[usar][0] color[usar^(resp&1)].push_back(uk2); resp>>=1; color[usar^(resp&1)].push_back(uk1); resp>>=1; color[usar^1^(resp&1)].push_back(x1); color[usar^(resp&1)].push_back(x2); } else { color[usar^(resp==2)].push_back(qr[1]), color[usar^(resp==2)].push_back(qr[3]); } } continue; } */ vector<int> qr; for(int i = 0; i < sz && unknown.size(); i++, unknown.pop_back()) qr.push_back(color[usar][i]), qr.push_back(unknown.back()); int resp = use_machine(qr); color[usar ^ (resp&1)].push_back(qr.back()); cnt[usar^1] += resp/2; cnt[usar] += (qr.size() / 2 - 1) - resp/2; } return cnt[0] + color[0].size(); }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:23:136: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |    for(; (max(color[0].size(), color[1].size()) < 3 || min(color[0].size(), color[1].size()) < 2) && color[0].size() + color[1].size() < qtd_min && unknown.size() > 2;) {
      |                                                                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
mushrooms.cpp:92:1: error: expected '}' at end of input
   92 | }
      | ^
mushrooms.cpp:10:28: note: to match this '{'
   10 | int count_mushrooms(int N) {
      |                            ^
mushrooms.cpp:15:25: warning: control reaches end of non-void function [-Wreturn-type]
   15 |  vector<int> unknown(N-1);
      |                         ^