답안 #640874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640874 2022-09-15T12:39:39 Z Alexandruabcde Homework (CEOI22_homework) C++14
13 / 100
210 ms 92364 KB
#include <bits/stdc++.h>

using namespace std;

struct Node {
   int st, dr;

   int sz;

   Node () {
      st = 1, dr = 0;

      sz = 0;
   }
};

string S;
int pos = 0;

Node Join (Node a, Node b, bool op) {
   Node ans;
   ans.sz = a.sz + b.sz;

   if (op == false) {
      ans.st = min(a.st, b.st);
      ans.dr = a.dr + b.dr - 1;
   }
   else {
      ans.st = min(b.dr + a.st, b.st + a.dr);
      ans.dr = max(a.dr + b.sz, a.sz + b.dr);
   }

   ans.sz = a.sz + b.sz;

   return ans;
}

Node Eval () {
   if (S[pos] == '?') {
      Node ans;

      ans.st = 1, ans.dr = 1, ans.sz = 1;

      return ans;
   }

   bool op = 0;
   if (S[pos] == 'm' && S[pos+1] == 'a' && S[pos+2] == 'x') op = 1;

   Node a, b;

   pos += 4;

   a = Eval();
   pos += 2;
   b = Eval();
   ++ pos;

   return Join(a, b, op);
}

int main () {
   cin >> S;

   Node ans = Eval();

   cout << ans.dr - ans.st + 1 << '\n';
   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 296 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 296 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 194 ms 90340 KB Output is correct
2 Correct 198 ms 90836 KB Output is correct
3 Correct 201 ms 90456 KB Output is correct
4 Correct 199 ms 92132 KB Output is correct
5 Correct 193 ms 91800 KB Output is correct
6 Correct 192 ms 92084 KB Output is correct
7 Correct 195 ms 91392 KB Output is correct
8 Correct 197 ms 91596 KB Output is correct
9 Correct 196 ms 90760 KB Output is correct
10 Correct 210 ms 90316 KB Output is correct
11 Correct 195 ms 92364 KB Output is correct
12 Correct 202 ms 90716 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 296 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 296 KB Output isn't correct
7 Halted 0 ms 0 KB -