| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 925900 | ttamx | Homework (CEOI22_homework) | C++14 | 224 ms | 172080 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using pi = pair<int,int>;
const int N=2e6+5;
int n;
int t[N];
string s;
stack<int> st;
vector<int> adj[N];
struct Info{
int l,m,r;
Info():l(0),m(1),r(0){}
int sz(){
return l+m+r;
}
}dp[N];
void dfs(int u){
if(t[u]==0)return;
for(auto v:adj[u])dfs(v);
Info dl=dp[adj[u][0]],dr=dp[adj[u][1]];
int tot=dl.sz()+dr.sz();
if(t[u]==-1){
dp[u].l=min(dl.l,dr.l);
dp[u].m=dl.l+dl.m+dr.l+dr.m-1-dp[u].l;
dp[u].r=tot-dp[u].l-dp[u].m;
}else{
dp[u].r=min(dl.r,dr.r);
dp[u].m=dl.r+dl.m+dr.r+dr.m-1-dp[u].r;
dp[u].l=tot-dp[u].r-dp[u].m;
}
}
void pop(){
int u=st.top();
st.pop();
int p=st.top();
adj[p].emplace_back(u);
if(adj[p].size()==2)pop();
}
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> s;
st.emplace(0);
for(int i=0;i<s.size();i++){
if(s[i]==','||s[i]=='('||s[i]==')')continue;
st.emplace(++n);
if(s[i]=='?'){
t[n]=0;
pop();
}else if(s.substr(i,3)=="min"){
t[n]=-1;
i+=2;
}else{
t[n]=1;
i+=2;
}
}
dfs(1);
cout << dp[1].m;
}컴파일 시 표준 에러 (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... | ||||
