제출 #884485

#제출 시각아이디문제언어결과실행 시간메모리
884485weajink버섯 세기 (IOI20_mushrooms)C++17
80.71 / 100
6 ms968 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef LOCAL
#define debug(...) __VA_ARGS__
#else
#define debug(...) {}
#endif

int count_mushrooms(int n){
    vector<int> znane[2];
    znane[0].push_back(0);
    int ile[2];
    ile[0] = 1;
    ile[1] = 0;
    int akt = 1;
    while (akt < n){
        bool better = (znane[0].size()<znane[1].size());
        int pt = 0;
        vector<int> zap;
        for (; akt < n && pt < znane[better].size(); akt++,pt++){
            zap.push_back(znane[better][pt]);
            zap.push_back(akt);
        }
        int wy = use_machine(zap);
        if (wy%2) znane[!better].push_back(akt-1);
        else znane[better].push_back(akt-1);
        ile[better] += pt-(wy+1)/2;
        ile[!better] += (wy+1)/2;
    }
    return ile[0];
}

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:22:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (; akt < n && pt < znane[better].size(); akt++,pt++){
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...