답안 #748220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748220 2023-05-25T17:25:45 Z DJeniUp 버섯 세기 (IOI20_mushrooms) C++17
0 / 100
16 ms 852 KB
#include "mushrooms.h"
#include "bits/stdc++.h"
 
using namespace std;
 
typedef int ll;
 
#define pb push_back
ll k;
 
ll S(vector<ll>v,ll x,ll y){
    if(v.size()==2)return x^1+y^1;
    vector<ll>a(0),b(0);
    for(int i=0;i<v.size();i++){
        if(i%2==0 && i!=v.size()-1){
            a.pb(v[i]);
        }else{
            b.pb(v[i]);
        }
    }
    //cout<<a.size()<<" "<<b.size()<<endl;
    
    ll r1=0;
    ll res1=0;
    if(a.size()>1){
        k++;
        if(k>20000)exit(1);
        r1=use_machine(a);
        res1=(r1/2+1)+(r1+1)/2;
        if(res1==a.size()){
            if(x==0)res1=(r1/2+1);
            else res1=(r1+1)/2;
        }else if(r1==0){
            if(x==0)res1=a.size();
            else res1=0;
        }else{
            if(r1%2==0){
                res1=S(a,x,x);
            }else res1=S(a,x,x^1);
        }
    }else res1=x^1;
    ll r2=0;
    ll res2=0;
    if(b.size()>1){
        k++;
        if(k>20000)exit(1);
        r2=use_machine(b);
        res2=(r2/2+1)+(r2+1)/2;
        if(res2==b.size()){
            if(y==0)res2=(r2/2+1);
            else res2=(r2+1)/2;
        }else if(r2==0){
            if(y==0)res2=b.size();
            else res2=0;
        }else{
            if(r2%2==0){
                res2=S(b,y,y);
            }else res2=S(b,y^1,y);
        }
    }else res2=y^1;
    return res1+res2;
}
 
int count_mushrooms(int n) {
    vector<ll>v(n);
    for(int i=0;i<n;i++){
        v[i]=i;
    }
    k=1;
    ll g=use_machine(v);
    if(g%2==0)return S(v,0,0);
    else return S(v,0,1);
}

Compilation message

mushrooms.cpp: In function 'll S(std::vector<int>, ll, ll)':
mushrooms.cpp:12:30: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   12 |     if(v.size()==2)return x^1+y^1;
      |                             ~^~
mushrooms.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
mushrooms.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         if(i%2==0 && i!=v.size()-1){
      |                      ~^~~~~~~~~~~~
mushrooms.cpp:30:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(res1==a.size()){
      |            ~~~~^~~~~~~~~~
mushrooms.cpp:49:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         if(res2==b.size()){
      |            ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 304 KB Output is correct
6 Partially correct 16 ms 332 KB Output is partially correct
7 Incorrect 11 ms 852 KB Too many total array sizes as queries.
8 Halted 0 ms 0 KB -