# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
956752 |
2024-04-02T12:32:41 Z |
Lukap |
Homework (CEOI22_homework) |
C++14 |
|
1000 ms |
32312 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6;
string s;
int n, uk;
int l[MAXN], r[MAXN], tip[MAXN];
vector<int> v;
void unos (int l_g, int r_g) {
int x = uk;
uk++;
if (r_g == l_g) {
n++;
return;
}
char a = s[l_g + 1];
int zag, br = 0;
for (int i = l_g; i <= r_g; i++) {
if (s[i] == '(') br++;
if (s[i] == ')') br--;
if (s[i] == ',' && br == 1) zag = i;
}
if (a == 'i') tip[x] = 0;
else tip[x] = 1;
l[x] = uk;
unos (l_g + 4, zag - 1);
r[x] = uk;
unos (zag + 1, r_g - 1);
}
int dfs (int x) {
// cout << x << ' ' << tip[x] << "\n";
if (tip[x] != tip[0] || l[x] == -1) return 1;
return dfs (l[x]) + dfs (r[x]);
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie (0);
cout.tie (0);
memset (l , -1, sizeof (l));
memset (r, -1, sizeof (r));
cin >> s;
unos (0, s.size () - 1);
int rj = dfs (0);
cout << n - rj + 1;
return 0;
}
Compilation message
Main.cpp: In function 'void unos(int, int)':
Main.cpp:36:10: warning: 'zag' may be used uninitialized in this function [-Wmaybe-uninitialized]
36 | unos (zag + 1, r_g - 1);
| ~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
17500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
17500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
32312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
17500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
17500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |