| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1119009 | PieArmy | Homework (CEOI22_homework) | C++17 | 146 ms | 80868 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
typedef long long ll;
ll pie(ll army){return (1ll<<army);}
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define mid ((left+right)>>1)
const ll inf=2000000000000000005;
const int sonsuz=2000000005;
using namespace std;
ll fpow(ll x,ll y,ll m=0){if(y<0){cout<<"powError";return -1;}if(m)x%=m;ll res=1;while(y>0){if(y&1)res*=x;x*=x;if(m){x%=m;res%=m;}y>>=1;}return res;}
int n;
int tip[1000001],alt[1000001][2];
pair<int,int> dfs(int pos){
	if(pos==0)return {0,0};
	pair<int,int>a=dfs(alt[pos][0]),b=dfs(alt[pos][1]);
	pair<int,int>res;
	if(tip[pos]==-1){
		res.fr=min(a.fr,b.fr);
		res.sc=a.sc+b.sc+1;
	}
	else{
		res.fr=a.fr+b.fr+1;
		res.sc=min(a.sc,b.sc);
	}
	return res;
}
void code(){
	string s;cin>>s;
	n=(s.size()+6)/7;
	int cur=1,child=0;
	vector<int>v={0};
	for(char c:s){
		if(c=='('||c==')'){
			child=0;
			if(c==')'){
				v.pop_back();
			}
		}
		if(c==','){
			child=1;
		}
		if(c=='x'||c=='n'){
			if(c=='x'){
				tip[cur]=1;
			}
			else tip[cur]=-1;
			alt[v.back()][child]=cur;
			v.pb(cur++);
		}
	}
	pair<int,int>ans=dfs(1);
	cout<<n-ans.fr-ans.sc;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
	int t=1;
	if(!t)cin>>t;
	while(t--){code();cout<<endl;}
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
