답안 #1034972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1034972 2024-07-26T01:24:51 Z pcc Homework (CEOI22_homework) C++17
10 / 100
224 ms 186264 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));
	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()){
      |         ~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 47196 KB Output is correct
2 Correct 52 ms 47192 KB Output is correct
3 Correct 50 ms 47212 KB Output is correct
4 Correct 51 ms 47196 KB Output is correct
5 Correct 54 ms 47196 KB Output is correct
6 Correct 52 ms 47196 KB Output is correct
7 Correct 52 ms 47192 KB Output is correct
8 Correct 51 ms 47196 KB Output is correct
9 Correct 51 ms 47196 KB Output is correct
10 Correct 71 ms 47196 KB Output is correct
11 Correct 52 ms 47196 KB Output is correct
12 Correct 52 ms 47420 KB Output is correct
13 Correct 52 ms 47192 KB Output is correct
14 Correct 55 ms 47412 KB Output is correct
15 Correct 53 ms 47196 KB Output is correct
16 Correct 51 ms 47192 KB Output is correct
17 Correct 52 ms 47192 KB Output is correct
18 Correct 50 ms 47180 KB Output is correct
19 Correct 54 ms 47196 KB Output is correct
20 Correct 58 ms 47416 KB Output is correct
21 Correct 55 ms 47196 KB Output is correct
22 Correct 62 ms 47412 KB Output is correct
23 Correct 52 ms 47192 KB Output is correct
24 Correct 51 ms 47192 KB Output is correct
25 Correct 26 ms 47196 KB Output is correct
26 Correct 24 ms 47352 KB Output is correct
27 Correct 24 ms 47192 KB Output is correct
28 Correct 22 ms 47196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 47196 KB Output is correct
2 Correct 52 ms 47192 KB Output is correct
3 Correct 50 ms 47212 KB Output is correct
4 Correct 51 ms 47196 KB Output is correct
5 Correct 54 ms 47196 KB Output is correct
6 Correct 52 ms 47196 KB Output is correct
7 Correct 52 ms 47192 KB Output is correct
8 Correct 51 ms 47196 KB Output is correct
9 Correct 51 ms 47196 KB Output is correct
10 Correct 71 ms 47196 KB Output is correct
11 Correct 52 ms 47196 KB Output is correct
12 Correct 52 ms 47420 KB Output is correct
13 Correct 52 ms 47192 KB Output is correct
14 Correct 55 ms 47412 KB Output is correct
15 Correct 53 ms 47196 KB Output is correct
16 Correct 51 ms 47192 KB Output is correct
17 Correct 52 ms 47192 KB Output is correct
18 Correct 50 ms 47180 KB Output is correct
19 Correct 54 ms 47196 KB Output is correct
20 Correct 58 ms 47416 KB Output is correct
21 Correct 55 ms 47196 KB Output is correct
22 Correct 62 ms 47412 KB Output is correct
23 Correct 52 ms 47192 KB Output is correct
24 Correct 51 ms 47192 KB Output is correct
25 Correct 26 ms 47196 KB Output is correct
26 Correct 24 ms 47352 KB Output is correct
27 Correct 24 ms 47192 KB Output is correct
28 Correct 22 ms 47196 KB Output is correct
29 Incorrect 21 ms 47192 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 224 ms 186264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 47196 KB Output is correct
2 Correct 52 ms 47192 KB Output is correct
3 Correct 50 ms 47212 KB Output is correct
4 Correct 51 ms 47196 KB Output is correct
5 Correct 54 ms 47196 KB Output is correct
6 Correct 52 ms 47196 KB Output is correct
7 Correct 52 ms 47192 KB Output is correct
8 Correct 51 ms 47196 KB Output is correct
9 Correct 51 ms 47196 KB Output is correct
10 Correct 71 ms 47196 KB Output is correct
11 Correct 52 ms 47196 KB Output is correct
12 Correct 52 ms 47420 KB Output is correct
13 Correct 52 ms 47192 KB Output is correct
14 Correct 55 ms 47412 KB Output is correct
15 Correct 53 ms 47196 KB Output is correct
16 Correct 51 ms 47192 KB Output is correct
17 Correct 52 ms 47192 KB Output is correct
18 Correct 50 ms 47180 KB Output is correct
19 Correct 54 ms 47196 KB Output is correct
20 Correct 58 ms 47416 KB Output is correct
21 Correct 55 ms 47196 KB Output is correct
22 Correct 62 ms 47412 KB Output is correct
23 Correct 52 ms 47192 KB Output is correct
24 Correct 51 ms 47192 KB Output is correct
25 Correct 26 ms 47196 KB Output is correct
26 Correct 24 ms 47352 KB Output is correct
27 Correct 24 ms 47192 KB Output is correct
28 Correct 22 ms 47196 KB Output is correct
29 Incorrect 21 ms 47192 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 47196 KB Output is correct
2 Correct 52 ms 47192 KB Output is correct
3 Correct 50 ms 47212 KB Output is correct
4 Correct 51 ms 47196 KB Output is correct
5 Correct 54 ms 47196 KB Output is correct
6 Correct 52 ms 47196 KB Output is correct
7 Correct 52 ms 47192 KB Output is correct
8 Correct 51 ms 47196 KB Output is correct
9 Correct 51 ms 47196 KB Output is correct
10 Correct 71 ms 47196 KB Output is correct
11 Correct 52 ms 47196 KB Output is correct
12 Correct 52 ms 47420 KB Output is correct
13 Correct 52 ms 47192 KB Output is correct
14 Correct 55 ms 47412 KB Output is correct
15 Correct 53 ms 47196 KB Output is correct
16 Correct 51 ms 47192 KB Output is correct
17 Correct 52 ms 47192 KB Output is correct
18 Correct 50 ms 47180 KB Output is correct
19 Correct 54 ms 47196 KB Output is correct
20 Correct 58 ms 47416 KB Output is correct
21 Correct 55 ms 47196 KB Output is correct
22 Correct 62 ms 47412 KB Output is correct
23 Correct 52 ms 47192 KB Output is correct
24 Correct 51 ms 47192 KB Output is correct
25 Correct 26 ms 47196 KB Output is correct
26 Correct 24 ms 47352 KB Output is correct
27 Correct 24 ms 47192 KB Output is correct
28 Correct 22 ms 47196 KB Output is correct
29 Incorrect 21 ms 47192 KB Output isn't correct
30 Halted 0 ms 0 KB -