제출 #825229

#제출 시각아이디문제언어결과실행 시간메모리
825229benjaminkleyn버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms208 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;

int count_mushrooms(int n)
{
    int A = 1, cnt = 0;
    int i;
    for (i = 0; i + 4 < n; i += 4)
    {
        int x = use_machine({i+0, i+1, i+2, i+3, i+4});

        if (x == 0)
            cnt += (A ? 4 : 0);
        else if (x == 1)
        {
            int y = use_machine({i+0, i+3, i+1, i+4, i+2});

            if (y == 1)
                cnt += (A ? 1 : 3);
            else if (y == 2)
                cnt += (A ? 4 : 0);
            else if (y == 3)
                cnt += 2;
            else if (y == 4)
                cnt += (A ? 3 : 1);
        }
        else if (x == 2)
        {
            int y = use_machine({i+1, i+0, i+2, i+4, i+3});

            if (y <= 2)
                cnt += (A ? 3 : 1);
            else if (y == 3)
                cnt += 2;
            else if (y == 4)
                cnt += (A ? 1 : 3);
                  
        }
        else if (x == 3)
        {
            int y = use_machine({i+3, i+1, i+2, i+0, i+4});

            if (y == 2)
                cnt += 2;
            else if (y == 3)
                cnt += (A ? 3 : 1);
        }
        else if (x == 4)
            cnt += 2;
    }
    cnt += A;
    for (int j = i + 1; j < n; j++)
        cnt += 1 - use_machine({0, j});
    return cnt;
}
#Verdict Execution timeMemoryGrader output
Fetching results...