# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
707269 | NemanjaSo2005 | 버섯 세기 (IOI20_mushrooms) | C++14 | 9 ms | 592 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll N,sta[20005],D=139;
bool inv;
vector<int> x,A,B,R;
stack<int> S;
int count_mushrooms(int n){
N=n;
if(N<=227){
sta[0]=1;
for(int i=0;i+1<N;i++){
x.clear();
x.push_back(i);
x.push_back(i+1);
sta[i+1]=sta[i]^use_machine(x);
}
ll res=0;
for(int i=0;i<N;i++)
res+=sta[i];
return res;
}
ll res=1;
for(int i=0;i<N;i++)
sta[i]=2;
sta[0]=1;
A.push_back(0);
for(int i=0;i+1<N;i++){
if(A.size()>=D or B.size()>=D)
break;
//cout<<i<<endl;
if((A.size()<2 and B.size()<2) or (i+2==N)){
x.clear();
x.push_back(i);
x.push_back(i+1);
sta[i+1]=sta[i]^use_machine(x);
if(sta[i+1]==1){
A.push_back(i+1);
res++;
}
else
B.push_back(i+1);
// cout<<"DODAJEM "<<i+1<<endl;
}
else{
if(A.size()>=2){
x.clear();
x.push_back(A[0]);
x.push_back(i+1);
x.push_back(A[1]);
x.push_back(i+2);
int r=use_machine(x);
if(r>=2)
sta[i+1]=0;
else
sta[i+1]=1;
if(r%2==1)
sta[i+2]=0;
else
sta[i+2]=1;
}
else{
x.clear();
x.push_back(B[0]);
x.push_back(i+1);
x.push_back(B[1]);
x.push_back(i+2);
int r=use_machine(x);
if(r>=2)
sta[i+1]=1;
else
sta[i+1]=0;
if(r%2==1)
sta[i+2]=1;
else
sta[i+2]=0;
}
if(sta[i+1]==1){
A.push_back(i+1);
res++;
}
else
B.push_back(i+1);
if(sta[i+2]==1){
A.push_back(i+2);
res++;
}
else
B.push_back(i+2);
// cout<<"DODAJEM "<<i+1<<endl;
// cout<<"DODAJEM "<<i+2<<endl;
i++;
}
}
if(A.size()>B.size()){
R=A;
inv=1;
}
else{
R=B;
inv=0;
}
for(int i=0;i<N;i++)
if(sta[i]==2)
S.push(i);
int pok;
// cout<<res<<endl;
while(S.size()){
x.clear();
x.push_back(R[0]);
pok=1;
while(pok<R.size() and S.size()){
x.push_back(S.top());
S.pop();
x.push_back(R[pok]);
pok++;
}
bool dod=false;
if(S.size()){
dod=true;
x.push_back(S.top());
S.pop();
}
int r=use_machine(x);
if(inv){
res+=((x.size()-1)-r)/2;
if(r%2==0 and dod)
res++;
}
else{
res+=(r)/2;
if(r%2==1 and dod)
res++;
}
//cout<<res<<endl;
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |