Submission #431879

#TimeUsernameProblemLanguageResultExecution timeMemory
431879OzyCounting Mushrooms (IOI20_mushrooms)C++17
25 / 100
110 ms276 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

lli res,a,pos;

int count_mushrooms(int n) {

    res = 1;
    rep(i,1,n/2) {
        pos = i*2;
        if (pos < n) {
            a = use_machine({pos-1,0,pos});
            if (a == 0) res += 2;
            else if (a == 1) res++;
        }
        else {
            a = use_machine({pos-1,0});
            if (a == 0) res++;
        }
    }

    return res;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:18:33: warning: narrowing conversion of '(pos - 1)' from 'long long int' to 'int' [-Wnarrowing]
   18 |             a = use_machine({pos-1,0,pos});
      |                              ~~~^~
mushrooms.cpp:18:33: warning: narrowing conversion of '(pos - 1)' from 'long long int' to 'int' [-Wnarrowing]
mushrooms.cpp:18:38: warning: narrowing conversion of 'pos' from 'long long int' to 'int' [-Wnarrowing]
   18 |             a = use_machine({pos-1,0,pos});
      |                                      ^~~
mushrooms.cpp:18:38: warning: narrowing conversion of 'pos' from 'long long int' to 'int' [-Wnarrowing]
mushrooms.cpp:23:33: warning: narrowing conversion of '(pos - 1)' from 'long long int' to 'int' [-Wnarrowing]
   23 |             a = use_machine({pos-1,0});
      |                              ~~~^~
mushrooms.cpp:23:33: warning: narrowing conversion of '(pos - 1)' from 'long long int' to 'int' [-Wnarrowing]
#Verdict Execution timeMemoryGrader output
Fetching results...