Submission #1364766

#TimeUsernameProblemLanguageResultExecution timeMemory
1364766ByeWorldCounting Mushrooms (IOI20_mushrooms)C++20
Compilation error
0 ms0 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "Ofast")
#define ll long long
#define se second
#define fi first
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define USE use_machine
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> ipii;
const int MAXN = 6e5+10;
const int MAXA = 5e4+10;
const int SQRT = 300;
const int INF = 2e9;
const int MOD = 1e9+87;
const int MOD2 = 1e9+7;
const int LOG = 30;

int n;
int count_mushrooms(int N) {
	n = N;
	vector<int> a = {0}, b;
	for(int i=1; i<=min(n-1, 200); i++){
		vector<int> m = {0, i};
		if(USE(m) == 1) b.pb(i);
		else a.pb(i);
	}
	if(n-1 <= 200){
		return a.size();
	}

	// cout << a.size() << ' '<< b.size()<< ' ' << "pp\n";
	int ans = a.size(), nw = 201;

	while(true){
		if(b.size() < a.size()){//pake a
			vector<int> m;
			int tot = 0, dep = 0; 
			while(nw <= n-1){
				if(m.empty()) dep = nw;
				m.pb(nw); m.pb(a[tot]); 
				tot++; nw++;

				if(tot == a.size()){
					// cout << m.size() << " msiz\n";
					int ret = USE(m);
					ans += tot-1-ret/2; // ret/2 = b
					if(ret%2 == 1) b.pb(nw); // ada b di depan
					else {
						ans++; a.pb(nw);
					}
					m.clear();
					tot = 0;
					break;
				}
			}
			if(!m.empty()){
					// cout << m.size() << " msiz\n";
				int ret = USE(m);
				ans += tot-1-ret/2; // ret/2 = b
				if(ret%2 == 1) b.pb(nw); // ada b di depan
				else {
					ans++; a.pb(nw);
				}
				else ans++;
			}

		} else {//pake b
			vector<int> m;
			int tot = 0, dep = 0; 
			while(nw <= n-1){
				if(m.empty()) dep = nw;
				m.pb(nw); m.pb(b[tot]); 
				tot++; nw++;

				if(tot == b.size()){
					int ret = USE(m);
					ans += ret/2; // ret/2 = b
					if(ret%2 == 1) ans++, a.pb(nw);
					else {
						b.pb(nw); // ada b di depan
					}
					m.clear();
					tot = 0;
					break;
				}
			}
			if(!m.empty()){
				int ret = USE(m);
				ans += ret/2; // ret/2 = b
				if(ret%2 == 1) ans++, a.pb(nw);
				else {
					b.pb(nw); // ada b di depan
				}
			}

		}
	}

	return ans;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:69:33: error: expected '}' before 'else'
   69 |                                 else ans++;
      |                                 ^~~~
mushrooms.cpp:61:39: note: to match this '{'
   61 |                         if(!m.empty()){
      |                                       ^
mushrooms.cpp:72:19: error: 'else' without a previous 'if'
   72 |                 } else {//pake b
      |                   ^~~~
mushrooms.cpp: At global scope:
mushrooms.cpp:104:9: error: expected unqualified-id before 'return'
  104 |         return ans;
      |         ^~~~~~
mushrooms.cpp:105:1: error: expected declaration before '}' token
  105 | }
      | ^