답안 #1001515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1001515 2024-06-19T05:14:48 Z irmuun 버섯 세기 (IOI20_mushrooms) C++17
0 / 100
1 ms 440 KB
#include<bits/stdc++.h>
#include "mushrooms.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int count_mushrooms(int n){
    int ans=0;
    vector<int>a,b;
    a.pb(0);
    for(int i=1;i<min(n,200);i++){
        int d=use_machine({0,i});
        if(d==0){
            a.pb(i);
        }
        else{
            b.pb(i);
        }
    }
    if(n<200){
        return (int)a.size();
    }
    ans=a.size();
    if(b.size()>a.size()){
        int len=b.size();
        len-=2;
        for(int i=200;i<n;i+=len){
            int r=min(i+len,n-1);
            int cur=0;
            vector<int>v;
            v.pb(b[0]);
            for(int j=i;j<=r;j++){
                v.pb(j);
                v.pb(b[++cur]);
            }
            for(int j=cur+1;j<b.size();j++){
                v.pb(b[j]);
            }
            ans+=use_machine(v)/2;
        }
    }
    else{
        int len=a.size();
        len-=2;
        for(int i=200;i<n;i+=len){
            int r=min(i+len,n-1);
            int cur=0;
            vector<int>v;
            v.pb(a[0]);
            int cnt=0;
            for(int j=i;j<=r;j++){
                v.pb(j);
                cnt++;
                v.pb(a[++cur]);
            }
            for(int j=cur+1;j<a.size();j++){
                v.pb(a[j]);
            }
            ans+=cnt-use_machine(v)/2;
        }
    }
    return ans;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:42:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for(int j=cur+1;j<b.size();j++){
      |                             ~^~~~~~~~~
mushrooms.cpp:62:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             for(int j=cur+1;j<a.size();j++){
      |                             ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 440 KB Answer is not correct.
7 Halted 0 ms 0 KB -