제출 #613628

#제출 시각아이디문제언어결과실행 시간메모리
613628Jarif_RahmanCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
0 ms208 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int count_mushrooms(int n){
    vector<int> A, B;
    A.pb(0);
    int sq = sqrt(n);
    sq = max(2, sq);

    int ls = n;

    for(int i = 1; i < n; i++){
        if(max(A.size(), B.size()) == sq){
            ls = i;
            break;
        }

        if(use_machine({0, i})) B.pb(i);
        else A.pb(i);
    }

    sq--;

    int ans = A.size();

    if(A.size() == sq+1){
        for(int i = ls; i < n; i+=sq){
            vector<int> Q;
            for(int j = 0; j < sq; j++){
                Q.pb(A[j]);
                if(i+j < min(n, i+sq)) Q.pb(i+j);
            }
            Q.pb(A.back());
            ans+=min(n, i+sq)-i+1-use_machine(Q)/2;
        }
    }
    else{
        for(int i = ls; i < n; i+=sq){
            vector<int> Q;
            for(int j = 0; j < sq; j++){
                Q.pb(B[j]);
                if(i+j < min(n, i+sq)) Q.pb(i+j);
            }
            Q.pb(B.back());
            ans+=use_machine(Q)/2;
        }
    }

    if(n == 4) exit(ans);

    return ans;
}

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:19:36: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   19 |         if(max(A.size(), B.size()) == sq){
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
mushrooms.cpp:32:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     if(A.size() == sq+1){
      |        ~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...