Submission #639787

# Submission time Handle Problem Language Result Execution time Memory
639787 2022-09-11T15:54:28 Z guest35178 Homework (CEOI22_homework) C++17
100 / 100
152 ms 17264 KB
#include<bits/stdc++.h>
using namespace std;

#define db(val) "["#val" = "<<(val)<<"] "
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define FOD(i,l,r) for(int i=(l);i>=(r);i--)
#define REP(i,l,r) for(int i=(l);i<(r);i++)

#define task ""

#define all(v) v.begin(),v.end()
#define uniq(v) v.resize(unique(all(v))-v.begin())
#define siz(v) (int32_t)(v.size())

#define left L392324
#define data UWU
#define right H392324

mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());

using ll=long long;
using pii=pair<int,int>;

template<class T,class U> void MAX(T &x,U y){if(x<y)x=y;}
template<class T,class U> void MIN(T &x,U y){if(y<x)x=y;}

inline ll rand(ll l,ll r){
   return uniform_int_distribution<ll>(l,r)(rd);
}

void RESET();
void AC();

void sinhtest(){
   ofstream cout("input.txt");

   cout.close();
}

int32_t main(){
   cin.tie(0)->ios::sync_with_stdio(0);

//   sinhtest();

   #ifdef trinhcham
      freopen("test_input.inp","r",stdin);
      freopen("test_output.out","w",stdout);
   #else
      if(fopen("input.txt","r")){
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
         freopen(".log","w",stderr);
      }else if(fopen(task".inp","r")){
         freopen(task".inp","r",stdin);
         freopen(task".out","w",stdout);
      }
   #endif

   /// [=============================]
         constexpr bool MULTITEST=0;
   /// [=============================]

   ll TESTCASES=1;
   if(MULTITEST)cin>>TESTCASES;

   FOR(test,1,TESTCASES){
      RESET();
      AC();
      cout<<'\n';
   }
}

void RESET(){

}

void AC(){
   using tp=tuple<int,int,int>;
   stack<int> dau;
   stack<tp> so;
   #define Max 1
   #define Min 0
   char c;
   while(cin>>c){
      if(c=='m'){///m**(
         char s;cin>>s;
         if(s=='a'){///max
            dau.push(Max);
         }else{///min
            dau.push(Min);
         }
         cin>>s>>s;
      }else if(c=='?'){///?
         so.emplace(1,1,1);
      }else if(c==')'){
         int curd=dau.top();
         dau.pop();
         int L,a,b,R,c,d;
         tie(L,a,b)=so.top();
         so.pop();
         tie(R,c,d)=so.top();
         so.pop();
         if(curd==Max)
            so.emplace(L+R,a+c,max(L+d,R+b));
         else so.emplace(L+R,min(a,c),b+d-1);
      }
      ///skip ,
   }
   int _,l,r;tie(_,l,r)=so.top();
   cout<<r-l+1;
}















Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:50:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |          freopen("input.txt","r",stdin);
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:51:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |          freopen("output.txt","w",stdout);
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:52:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |          freopen(".log","w",stderr);
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:54:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |          freopen(task".inp","r",stdin);
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:55:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |          freopen(task".out","w",stdout);
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 320 KB Output is correct
32 Correct 1 ms 228 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 328 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 328 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 0 ms 324 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 224 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 324 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 0 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 15304 KB Output is correct
2 Correct 126 ms 15844 KB Output is correct
3 Correct 131 ms 15416 KB Output is correct
4 Correct 122 ms 17112 KB Output is correct
5 Correct 112 ms 16792 KB Output is correct
6 Correct 123 ms 16980 KB Output is correct
7 Correct 113 ms 16336 KB Output is correct
8 Correct 113 ms 16656 KB Output is correct
9 Correct 129 ms 15704 KB Output is correct
10 Correct 123 ms 15316 KB Output is correct
11 Correct 121 ms 17264 KB Output is correct
12 Correct 142 ms 15720 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 320 KB Output is correct
32 Correct 1 ms 228 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 328 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 328 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 0 ms 324 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 224 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 324 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 0 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 328 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 1 ms 340 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 1 ms 340 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 1 ms 340 KB Output is correct
78 Correct 1 ms 212 KB Output is correct
79 Correct 1 ms 212 KB Output is correct
80 Correct 1 ms 340 KB Output is correct
81 Correct 1 ms 340 KB Output is correct
82 Correct 1 ms 340 KB Output is correct
83 Correct 1 ms 212 KB Output is correct
84 Correct 1 ms 212 KB Output is correct
85 Correct 1 ms 212 KB Output is correct
86 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 320 KB Output is correct
32 Correct 1 ms 228 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 328 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 328 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 0 ms 324 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 224 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 324 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 0 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 113 ms 15304 KB Output is correct
58 Correct 126 ms 15844 KB Output is correct
59 Correct 131 ms 15416 KB Output is correct
60 Correct 122 ms 17112 KB Output is correct
61 Correct 112 ms 16792 KB Output is correct
62 Correct 123 ms 16980 KB Output is correct
63 Correct 113 ms 16336 KB Output is correct
64 Correct 113 ms 16656 KB Output is correct
65 Correct 129 ms 15704 KB Output is correct
66 Correct 123 ms 15316 KB Output is correct
67 Correct 121 ms 17264 KB Output is correct
68 Correct 142 ms 15720 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 1 ms 212 KB Output is correct
73 Correct 1 ms 328 KB Output is correct
74 Correct 1 ms 212 KB Output is correct
75 Correct 1 ms 212 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 1 ms 340 KB Output is correct
78 Correct 1 ms 340 KB Output is correct
79 Correct 1 ms 340 KB Output is correct
80 Correct 1 ms 212 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 1 ms 212 KB Output is correct
83 Correct 1 ms 212 KB Output is correct
84 Correct 1 ms 212 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 1 ms 340 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 1 ms 212 KB Output is correct
92 Correct 1 ms 212 KB Output is correct
93 Correct 1 ms 340 KB Output is correct
94 Correct 1 ms 340 KB Output is correct
95 Correct 1 ms 340 KB Output is correct
96 Correct 1 ms 212 KB Output is correct
97 Correct 1 ms 212 KB Output is correct
98 Correct 1 ms 212 KB Output is correct
99 Correct 1 ms 212 KB Output is correct
100 Correct 125 ms 6820 KB Output is correct
101 Correct 122 ms 6056 KB Output is correct
102 Correct 121 ms 5912 KB Output is correct
103 Correct 119 ms 6188 KB Output is correct
104 Correct 126 ms 5196 KB Output is correct
105 Correct 152 ms 8988 KB Output is correct
106 Correct 127 ms 8544 KB Output is correct
107 Correct 115 ms 8840 KB Output is correct
108 Correct 120 ms 9676 KB Output is correct
109 Correct 150 ms 10100 KB Output is correct
110 Correct 122 ms 6988 KB Output is correct
111 Correct 134 ms 5984 KB Output is correct
112 Correct 126 ms 6420 KB Output is correct
113 Correct 113 ms 5768 KB Output is correct
114 Correct 126 ms 6304 KB Output is correct
115 Correct 135 ms 16984 KB Output is correct
116 Correct 122 ms 16076 KB Output is correct
117 Correct 119 ms 16796 KB Output is correct
118 Correct 132 ms 16072 KB Output is correct
119 Correct 127 ms 15864 KB Output is correct
120 Correct 113 ms 6576 KB Output is correct
121 Correct 116 ms 6636 KB Output is correct
122 Correct 122 ms 6448 KB Output is correct
123 Correct 135 ms 6652 KB Output is correct
124 Correct 119 ms 15060 KB Output is correct
125 Correct 124 ms 14912 KB Output is correct
126 Correct 137 ms 14308 KB Output is correct
127 Correct 134 ms 15216 KB Output is correct
128 Correct 64 ms 3608 KB Output is correct
129 Correct 68 ms 3276 KB Output is correct
130 Correct 61 ms 3716 KB Output is correct
131 Correct 1 ms 212 KB Output is correct