# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
884591 | jamjanek | Counting Mushrooms (IOI20_mushrooms) | C++14 | 6 ms | 736 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
void wypiszvector(vector<int>&vec){
printf("{");
for(auto j: vec)printf("%d,", j);
printf("}\n");
}
const int stala = 2;
int maska[7] = {0,0,0,2,0,3,1,};
vector<int>zapytanie[7] = {{0,1,},{0,1,2,},{},{},{0,1,2,},{},{},};
vector<int>graf[7] = {{1,4,},{2,3,},{},{},{-1,5,6,},{},{},};
vector<int>A[2];
int Ac[2];
int it;
int count_mushrooms1(int n){
while(it<n){
// printf("it = %d\n", it);
vector<int>pom;
bool czy = 0;
if(A[1].size()>A[0].size())czy = 1;
int pom1 = 0;
while(it<n && pom.size()<2*A[czy].size()){
pom.push_back(A[czy][pom1++]);
pom.push_back(it);
it++;
}
int ans = use_machine(pom);
// printf("vec: = ");for(auto j: pom)printf("%d ", j);printf("\n");
// printf("ans = %d\n", ans);
if(ans%2==0)
A[czy].push_back(it-1);
else
A[!czy].push_back(it-1);
Ac[!czy]+=(ans+1)/2;
Ac[czy]+=pom1-(ans+1)/2;
if(pom1==2){
if(ans<2)
A[czy].push_back(it-2);
else
A[!czy].push_back(it-2);
}
}
// printf("res = %d\n", Ac[0]);
return Ac[0];
}
int count_mushrooms(int n){
A[0].push_back(0);
it = 1;
Ac[0] = 1;
Ac[1] = 0;
if(n<=stala+1)
return count_mushrooms1(n);
int x = 0;
while(graf[x].size()>0){
int c = use_machine(zapytanie[x]);
// wypiszvector(zapytanie[x]);
x = graf[x][c];
}
x = maska[x];
for(int i=0;i<stala;i++){
if((x>>i)&1){
A[1].push_back(i+1);
Ac[1]++;
}
else{
A[0].push_back(i+1);
Ac[0]++;
}
}
it = stala+1;
return count_mushrooms1(n);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |