# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
605305 | MohamedAliSaidane | Counting Mushrooms (IOI20_mushrooms) | C++14 | 0 ms | 208 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
#define pb push_back
#define popb pop_back
#define all(x) (x).begin(),(x).end()
int count_mushrooms(int n)
{
if(n == 2)
{
vi U;
U.pb(0); U.pb(1);
if(use_machine(U))
return 2;
else
return 1;
}
int ans[n];
ans[0] = 1;
vi U; U.pb(0); U.pb(1);
if(use_machine(U))
ans[1] = 0;
U.popb();
U.pb(2);
if(use_machine(U))
ans[2] = 0;
int ones = ans[0] + ans[1] + ans[2];
if(ones == 1)
{
int a = 1;
int b = 2;
for(int i = 3; i < n - 1; i += 2)
{
vi V;
V.pb(1);
V.pb(i);
V.pb(2);
V.pb(i + 1);
int rep = use_machine(V);
if(rep == 1)
{
ans[i] = ans[1];
ans[i + 1] = 1 - ans[1];
}
else if(rep == 2)
{
ans[i] = 1 - ans[1];
ans[i + 1] = ans[1];
}
else if(rep == 3)
{
ans[i] = 1 - ans[1];
ans[i + 1] = 1 - ans[1];
}
else
{
ans[i] = ans[1];
ans[i + 1] = ans[1];
}
}
if(n%2 == 0)
{
ans[n - 1] = use_machine({1, n - 1});
}
}
else
{
int a = 0;
int b = ans[1] ? 1: 2;
for(int i = 3; i < n - 1; i += 2)
{
vi V;
V.pb(b);
V.pb(i);
V.pb(0);
V.pb(i + 1);
int rep = use_machine(V);
if(rep == 1)
{
ans[i] = ans[0];
ans[i + 1] = 1 - ans[0];
}
else if(rep == 2)
{
ans[i] = 1 - ans[0];
ans[i + 1] = ans[0];
}
else if(rep == 3)
{
ans[i] = 1 - ans[0];
ans[i + 1] = 1 - ans[0];
}
else
{
ans[i] = ans[0];
ans[i + 1] = ans[0];
}
}
if(n%2 == 0)
{
ans[n - 1] = 1 - use_machine({0, n - 1});
}
}
int fin = 0 ;
for(int i = 0 ; i < n; i++)
fin += ans[i];
return fin;
}
/*
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |