답안 #1104034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104034 2024-10-22T15:26:12 Z vjudge1 버섯 세기 (IOI20_mushrooms) C++14
0 / 100
8 ms 604 KB
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;

int count_mushrooms(int n){
    vector<int> w,b;
    char c;
    int s,ans=0;
    vector<int> arr={0,1};
    w.push_back(0);
    if(use_machine(arr)){
        b.push_back(1);
        arr={0,2};
        if(use_machine(arr)){
            b.push_back(2);
            c='b';
        } else {
            w.push_back(2);
            c='w';
        }
        s=3;
    } else {
        w.push_back(1);
        c='w';
        s=2;
    }
    int d=min(100,(n-s)/2);
    while(d--){
        if(c=='w'){
            arr={w[0],s,w[1],s+1};
            int tmp=use_machine(arr);
            if(tmp%2){
                b.push_back(s+1);
            } else {
                w.push_back(s+1);
            }
            if(tmp/2){
                b.push_back(s);
            } else {
                w.push_back(s);
            }
            s+=2;
        } else {
            arr={b[0],s,b[1],s+1};
            int tmp=use_machine(arr);
            if(tmp%2){
                w.push_back(s+1);
            } else {
                b.push_back(s+1);
            }
            if(tmp/2){
                w.push_back(s);
            } else {
                b.push_back(s);
            }
            s+=2;
        }
    }
    ans=w.size();
    int sz=max(b.size(),w.size());
    while(n-s>=sz){
        arr.clear();
        if(w.size()>b.size()){
            for(int i=0;i<sz;i++,s++){
                arr.push_back(w[i]);
                arr.push_back(s);
            }
            int t=use_machine(arr);
            if(t%2)b.push_back(s-1);
            else w.push_back(s-1);
            ans+=sz-(t+1)/2;
        } else {
            for(int i=0;i<sz;i++,s++){
                arr.push_back(b[i]);
                arr.push_back(s);
            }
            int t=use_machine(arr);
            if(t%2)w.push_back(s-1);
            else b.push_back(s-1);
            ans+=(t+1)/2;
        }
        sz=max(b.size(),w.size());
    }
    arr.clear();
    if(w.size()>b.size()&&s<n){
        for(int i=0;s<n;i++,s++){
            arr.push_back(w[i]);
            arr.push_back(s);
        }
        int t=use_machine(arr);
        ans+=(arr.size())/2-(t+1)/2;
    } else if(s<n){
        for(int i=0;s<n;i++,s++){
            arr.push_back(b[i]);
            arr.push_back(s);
        }
        int t=use_machine(arr);
        ans+=(t+1)/2;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 7 ms 336 KB Output is correct
10 Correct 6 ms 336 KB Output is correct
11 Partially correct 4 ms 336 KB Output is partially correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 4 ms 336 KB Output is correct
14 Correct 4 ms 336 KB Output is correct
15 Partially correct 5 ms 336 KB Output is partially correct
16 Partially correct 4 ms 336 KB Output is partially correct
17 Correct 3 ms 336 KB Output is correct
18 Correct 4 ms 592 KB Output is correct
19 Partially correct 5 ms 456 KB Output is partially correct
20 Correct 4 ms 336 KB Output is correct
21 Correct 4 ms 336 KB Output is correct
22 Partially correct 5 ms 592 KB Output is partially correct
23 Correct 5 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Partially correct 5 ms 336 KB Output is partially correct
26 Partially correct 5 ms 348 KB Output is partially correct
27 Partially correct 5 ms 336 KB Output is partially correct
28 Partially correct 6 ms 336 KB Output is partially correct
29 Partially correct 7 ms 336 KB Output is partially correct
30 Partially correct 4 ms 336 KB Output is partially correct
31 Partially correct 5 ms 504 KB Output is partially correct
32 Partially correct 5 ms 504 KB Output is partially correct
33 Partially correct 5 ms 336 KB Output is partially correct
34 Partially correct 6 ms 336 KB Output is partially correct
35 Partially correct 5 ms 336 KB Output is partially correct
36 Partially correct 4 ms 336 KB Output is partially correct
37 Partially correct 5 ms 336 KB Output is partially correct
38 Partially correct 5 ms 336 KB Output is partially correct
39 Partially correct 5 ms 500 KB Output is partially correct
40 Partially correct 7 ms 452 KB Output is partially correct
41 Partially correct 7 ms 592 KB Output is partially correct
42 Partially correct 5 ms 504 KB Output is partially correct
43 Partially correct 4 ms 336 KB Output is partially correct
44 Partially correct 7 ms 336 KB Output is partially correct
45 Partially correct 4 ms 336 KB Output is partially correct
46 Partially correct 5 ms 336 KB Output is partially correct
47 Partially correct 4 ms 336 KB Output is partially correct
48 Partially correct 4 ms 336 KB Output is partially correct
49 Partially correct 7 ms 504 KB Output is partially correct
50 Partially correct 5 ms 460 KB Output is partially correct
51 Partially correct 5 ms 336 KB Output is partially correct
52 Partially correct 5 ms 336 KB Output is partially correct
53 Partially correct 4 ms 336 KB Output is partially correct
54 Partially correct 5 ms 444 KB Output is partially correct
55 Partially correct 6 ms 336 KB Output is partially correct
56 Partially correct 7 ms 604 KB Output is partially correct
57 Partially correct 6 ms 336 KB Output is partially correct
58 Partially correct 4 ms 336 KB Output is partially correct
59 Partially correct 5 ms 336 KB Output is partially correct
60 Partially correct 8 ms 336 KB Output is partially correct
61 Partially correct 6 ms 336 KB Output is partially correct
62 Correct 1 ms 336 KB Output is correct
63 Incorrect 1 ms 336 KB Invalid value 2 in the query array.
64 Halted 0 ms 0 KB -