Submission #1034990

# Submission time Handle Problem Language Result Execution time Memory
1034990 2024-07-26T02:12:23 Z pcc Homework (CEOI22_homework) C++17
10 / 100
221 ms 186272 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")

const int mxn = 1e6+10;
vector<int> tree[mxn*2];
int val[mxn*2],dp[mxn*2];
int vcnt = 0;
int N;
string s;
int rt;

void dfs(int now){
	if(val[now]<0)dp[now] = (val[now] == -1?mxn:-mxn);
	else dp[now] = val[now];
	for(auto nxt:tree[now]){
		dfs(nxt);
		if(val[now] == -2)dp[now] = max(dp[now],dp[nxt]);
		else dp[now] = min(dp[now],dp[nxt]);
	}
	return;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s;
	for(int i = 0;i<s.size();i++)N += s[i] == '?';
	{
		int pt = 0;
		vector<int> v,stk;
		while(pt<s.size()){
			if(s[pt] == 'm'){
				if(s.substr(pt,3) == "min"){
					v.push_back(-1);
				}
				else{
					v.push_back(-2);
				}
				pt += 3;
			}
			else if(s[pt] == '?'){
				v.push_back(++vcnt);
				pt++;
			}
			else pt++;
		}
		vcnt = N;
		for(auto &i:v){
			stk.push_back(i);
			while(stk.size()>=2&&stk.end()[-1]>0&&stk.end()[-2]>0){
				int a = stk.end()[-1],b = stk.end()[-2];
				stk.pop_back();stk.pop_back();
				int c = ++vcnt;
				tree[c].push_back(a);
				tree[c].push_back(b);
				assert(stk.back()<0);
				val[c] = stk.back();
				stk.pop_back();
				rt = c;
				stk.push_back(c);
			}
		}
	}
	dfs(rt);
	for(int i = 1;i<=N;i++)val[i] = i;
	set<int> st;
	if(N>10)return 0;
	do{
		dfs(rt);
		st.insert(dp[rt]);
	}while(next_permutation(val+1,val+N+1));
	vector<int> vv;
	for(auto &i:st)vv.push_back(i);
	for(int i = 1;i<vv.size();i++){
		assert(vv[i] == vv[i-1]+1);
	}
	cout<<st.size()<<'\n';
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(int i = 0;i<s.size();i++)N += s[i] == '?';
      |                ~^~~~~~~~~
Main.cpp:32:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   while(pt<s.size()){
      |         ~~^~~~~~~~~
Main.cpp:75:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |  for(int i = 1;i<vv.size();i++){
      |                ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 53 ms 47196 KB Output is correct
2 Correct 58 ms 47196 KB Output is correct
3 Correct 51 ms 47192 KB Output is correct
4 Correct 56 ms 47196 KB Output is correct
5 Correct 53 ms 47196 KB Output is correct
6 Correct 51 ms 47196 KB Output is correct
7 Correct 52 ms 47196 KB Output is correct
8 Correct 52 ms 47196 KB Output is correct
9 Correct 52 ms 47192 KB Output is correct
10 Correct 54 ms 47196 KB Output is correct
11 Correct 54 ms 47192 KB Output is correct
12 Correct 52 ms 47192 KB Output is correct
13 Correct 53 ms 47192 KB Output is correct
14 Correct 53 ms 47192 KB Output is correct
15 Correct 57 ms 47192 KB Output is correct
16 Correct 51 ms 47196 KB Output is correct
17 Correct 53 ms 47196 KB Output is correct
18 Correct 50 ms 47196 KB Output is correct
19 Correct 59 ms 47196 KB Output is correct
20 Correct 54 ms 47192 KB Output is correct
21 Correct 61 ms 47200 KB Output is correct
22 Correct 51 ms 47192 KB Output is correct
23 Correct 52 ms 47196 KB Output is correct
24 Correct 52 ms 47324 KB Output is correct
25 Correct 23 ms 47436 KB Output is correct
26 Correct 23 ms 47192 KB Output is correct
27 Correct 24 ms 47196 KB Output is correct
28 Correct 20 ms 47196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 47196 KB Output is correct
2 Correct 58 ms 47196 KB Output is correct
3 Correct 51 ms 47192 KB Output is correct
4 Correct 56 ms 47196 KB Output is correct
5 Correct 53 ms 47196 KB Output is correct
6 Correct 51 ms 47196 KB Output is correct
7 Correct 52 ms 47196 KB Output is correct
8 Correct 52 ms 47196 KB Output is correct
9 Correct 52 ms 47192 KB Output is correct
10 Correct 54 ms 47196 KB Output is correct
11 Correct 54 ms 47192 KB Output is correct
12 Correct 52 ms 47192 KB Output is correct
13 Correct 53 ms 47192 KB Output is correct
14 Correct 53 ms 47192 KB Output is correct
15 Correct 57 ms 47192 KB Output is correct
16 Correct 51 ms 47196 KB Output is correct
17 Correct 53 ms 47196 KB Output is correct
18 Correct 50 ms 47196 KB Output is correct
19 Correct 59 ms 47196 KB Output is correct
20 Correct 54 ms 47192 KB Output is correct
21 Correct 61 ms 47200 KB Output is correct
22 Correct 51 ms 47192 KB Output is correct
23 Correct 52 ms 47196 KB Output is correct
24 Correct 52 ms 47324 KB Output is correct
25 Correct 23 ms 47436 KB Output is correct
26 Correct 23 ms 47192 KB Output is correct
27 Correct 24 ms 47196 KB Output is correct
28 Correct 20 ms 47196 KB Output is correct
29 Incorrect 20 ms 47192 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 221 ms 186272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 47196 KB Output is correct
2 Correct 58 ms 47196 KB Output is correct
3 Correct 51 ms 47192 KB Output is correct
4 Correct 56 ms 47196 KB Output is correct
5 Correct 53 ms 47196 KB Output is correct
6 Correct 51 ms 47196 KB Output is correct
7 Correct 52 ms 47196 KB Output is correct
8 Correct 52 ms 47196 KB Output is correct
9 Correct 52 ms 47192 KB Output is correct
10 Correct 54 ms 47196 KB Output is correct
11 Correct 54 ms 47192 KB Output is correct
12 Correct 52 ms 47192 KB Output is correct
13 Correct 53 ms 47192 KB Output is correct
14 Correct 53 ms 47192 KB Output is correct
15 Correct 57 ms 47192 KB Output is correct
16 Correct 51 ms 47196 KB Output is correct
17 Correct 53 ms 47196 KB Output is correct
18 Correct 50 ms 47196 KB Output is correct
19 Correct 59 ms 47196 KB Output is correct
20 Correct 54 ms 47192 KB Output is correct
21 Correct 61 ms 47200 KB Output is correct
22 Correct 51 ms 47192 KB Output is correct
23 Correct 52 ms 47196 KB Output is correct
24 Correct 52 ms 47324 KB Output is correct
25 Correct 23 ms 47436 KB Output is correct
26 Correct 23 ms 47192 KB Output is correct
27 Correct 24 ms 47196 KB Output is correct
28 Correct 20 ms 47196 KB Output is correct
29 Incorrect 20 ms 47192 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 47196 KB Output is correct
2 Correct 58 ms 47196 KB Output is correct
3 Correct 51 ms 47192 KB Output is correct
4 Correct 56 ms 47196 KB Output is correct
5 Correct 53 ms 47196 KB Output is correct
6 Correct 51 ms 47196 KB Output is correct
7 Correct 52 ms 47196 KB Output is correct
8 Correct 52 ms 47196 KB Output is correct
9 Correct 52 ms 47192 KB Output is correct
10 Correct 54 ms 47196 KB Output is correct
11 Correct 54 ms 47192 KB Output is correct
12 Correct 52 ms 47192 KB Output is correct
13 Correct 53 ms 47192 KB Output is correct
14 Correct 53 ms 47192 KB Output is correct
15 Correct 57 ms 47192 KB Output is correct
16 Correct 51 ms 47196 KB Output is correct
17 Correct 53 ms 47196 KB Output is correct
18 Correct 50 ms 47196 KB Output is correct
19 Correct 59 ms 47196 KB Output is correct
20 Correct 54 ms 47192 KB Output is correct
21 Correct 61 ms 47200 KB Output is correct
22 Correct 51 ms 47192 KB Output is correct
23 Correct 52 ms 47196 KB Output is correct
24 Correct 52 ms 47324 KB Output is correct
25 Correct 23 ms 47436 KB Output is correct
26 Correct 23 ms 47192 KB Output is correct
27 Correct 24 ms 47196 KB Output is correct
28 Correct 20 ms 47196 KB Output is correct
29 Incorrect 20 ms 47192 KB Output isn't correct
30 Halted 0 ms 0 KB -