# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
725857 | 2023-04-18T07:44:12 Z | Baytoro | Homework (CEOI22_homework) | C++17 | 181 ms | 111620 KB |
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define ll long long #define int long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const ll INF=1e18,mod=1e9+9,N=2e6+5; vector<int> g[N]; int t[N]; int dfs(int x, int c){ //cout<<x<<endl; if(t[x]!=c) return 0; for(auto it: g[x]){ if(t[it]) return 1+dfs(it,c); } return 1; } void solve(){ string s;cin>>s;int n=s.size(), m=0; stack<int> st; int cur=0; for(int i=0;i<n;i++){ if(s[i]=='n'){ cur++; if(!st.empty()){ g[st.top()].pb(cur); } t[cur]=1; st.push(cur); } if(s[i]=='x'){ cur++; if(!st.empty()){ g[st.top()].pb(cur); } t[cur]=2; st.push(cur); } if(s[i]=='?'){ cur++;m++; g[st.top()].pb(cur); } if(s[i]==')') st.pop(); } assert(st.empty()); cout<<m-max(dfs(1,1),dfs(1,2)); } main(){ //fopn("team"); ios; int T=1; //cin>>T; for(int i=1;i<=T;i++){ //cout<<"Case #"<<i<<": "; solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 47188 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 47188 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 163 ms | 106296 KB | Output is correct |
2 | Correct | 181 ms | 111404 KB | Output is correct |
3 | Correct | 161 ms | 111344 KB | Output is correct |
4 | Correct | 169 ms | 111620 KB | Output is correct |
5 | Correct | 157 ms | 111368 KB | Output is correct |
6 | Correct | 155 ms | 111384 KB | Output is correct |
7 | Correct | 165 ms | 111400 KB | Output is correct |
8 | Correct | 154 ms | 111408 KB | Output is correct |
9 | Correct | 155 ms | 111560 KB | Output is correct |
10 | Correct | 158 ms | 111344 KB | Output is correct |
11 | Correct | 155 ms | 111304 KB | Output is correct |
12 | Correct | 160 ms | 111300 KB | Output is correct |
13 | Correct | 25 ms | 47316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 47188 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 47188 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |