# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
660269 | 2022-11-21T11:40:55 Z | berr | Palindromi (COCI22_palindromi) | C++17 | 1000 ms | 8276 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int N=2e5+37; string s[N]; int val[N]; int par[N]; int find(int x) { if(x==par[x]) return x; return par[x]=find(par[x]); } int check(string t) { for(int i=0; i<t.size(); i++) { if(t[i]!=t[t.size()-i-1]) return 0; } return 1; } void merge(int x, int y) { x=find(x); y=find(y); string t=s[x]+s[y]; set<string> st; for(int i=0; i<t.size(); i++) { string f; for(int l=i; l<t.size(); l++) { f+=t[l]; if(check(f)) { st.insert(f); } } } s[x]=t; val[x]=st.size(); par[y]=x; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin>>n; string sr; cin>>sr; for(int i=0; i<n; i++) { s[i]=sr[i]; val[i]=1; par[i]=i; } for(int i=0; i<n-1; i++) { int x, y; cin>>x>>y; x--; y--; merge(x, y); cout<<val[find(x)]<<endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 6504 KB | Output is correct |
2 | Correct | 9 ms | 6612 KB | Output is correct |
3 | Correct | 6 ms | 6484 KB | Output is correct |
4 | Correct | 12 ms | 6592 KB | Output is correct |
5 | Correct | 9 ms | 6484 KB | Output is correct |
6 | Correct | 21 ms | 6620 KB | Output is correct |
7 | Correct | 11 ms | 6484 KB | Output is correct |
8 | Correct | 17 ms | 6612 KB | Output is correct |
9 | Correct | 11 ms | 6484 KB | Output is correct |
10 | Correct | 17 ms | 6612 KB | Output is correct |
11 | Correct | 11 ms | 6592 KB | Output is correct |
12 | Correct | 4 ms | 6612 KB | Output is correct |
13 | Correct | 4 ms | 6592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 6504 KB | Output is correct |
2 | Correct | 9 ms | 6612 KB | Output is correct |
3 | Correct | 6 ms | 6484 KB | Output is correct |
4 | Correct | 12 ms | 6592 KB | Output is correct |
5 | Correct | 9 ms | 6484 KB | Output is correct |
6 | Correct | 21 ms | 6620 KB | Output is correct |
7 | Correct | 11 ms | 6484 KB | Output is correct |
8 | Correct | 17 ms | 6612 KB | Output is correct |
9 | Correct | 11 ms | 6484 KB | Output is correct |
10 | Correct | 17 ms | 6612 KB | Output is correct |
11 | Correct | 11 ms | 6592 KB | Output is correct |
12 | Correct | 4 ms | 6612 KB | Output is correct |
13 | Correct | 4 ms | 6592 KB | Output is correct |
14 | Correct | 3 ms | 6484 KB | Output is correct |
15 | Execution timed out | 1083 ms | 7048 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1089 ms | 8276 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 6504 KB | Output is correct |
2 | Correct | 9 ms | 6612 KB | Output is correct |
3 | Correct | 6 ms | 6484 KB | Output is correct |
4 | Correct | 12 ms | 6592 KB | Output is correct |
5 | Correct | 9 ms | 6484 KB | Output is correct |
6 | Correct | 21 ms | 6620 KB | Output is correct |
7 | Correct | 11 ms | 6484 KB | Output is correct |
8 | Correct | 17 ms | 6612 KB | Output is correct |
9 | Correct | 11 ms | 6484 KB | Output is correct |
10 | Correct | 17 ms | 6612 KB | Output is correct |
11 | Correct | 11 ms | 6592 KB | Output is correct |
12 | Correct | 4 ms | 6612 KB | Output is correct |
13 | Correct | 4 ms | 6592 KB | Output is correct |
14 | Correct | 3 ms | 6484 KB | Output is correct |
15 | Execution timed out | 1083 ms | 7048 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |