# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705002 | 2023-03-03T07:49:57 Z | Paul_Liao_1457 | Palindromi (COCI22_palindromi) | C++17 | 1000 ms | 1232 KB |
//記得跳題 //#pragma GCC optimize("O4,unroll_loops") //#pragma GCC target("avx2") #include<iostream> #include<array> #include<vector> #include<string> #include<algorithm> #include<set> #include<queue> #include<stack> #include<math.h> #include<map> #include<unordered_map> #include<unordered_set> #include<cstring> #include<iomanip> #include<bitset> #include<tuple> #include<random> #define ll long long #define FOR(i,a,b) for(int i=a;i<b;i++) #define REP(i,a,b) for(int i=a;i>=b;i--) #define pb push_back #define INF (ll)(2e18) #define F first #define S second #define endl "\n" #define AC ios::sync_with_stdio(0); using namespace std; int boss[1005],ans[1005]; string s[1005]; set<string> st[1005]; int find (int x) { if (boss[x] == x) return x; return boss[x] = find(boss[x]); } void merge(int a, int b) { int n = (int)s[a].size(); boss[b] = a; s[a]+=s[b]; //cout << "sa=" << s[a] << endl; FOR(mid, 0, s[a].size()) { int len = 1; string now; now += s[a][mid]; while (mid - len >= 0 && mid + len < s[a].size() && s[a][mid-len] == s[a][mid+len]) { now = now + s[a][mid+len]; now = s[a][mid-len] + now; if (mid - len + 1 <= n && mid + len + 1 > n) { st[a].insert(now); } len++; } int l = mid, r = mid+1; if (r<s[a].size() && s[a][l] == s[a][r]) { now.clear(); now += s[a][l]; now += s[a][r]; st[a].insert(now); while (l-1 >= 0 && r+1 < s[a].size() && s[a][l-1] == s[a][r+1]) { l--; r++; now = now + s[a][r]; now = s[a][l] + now; if (l+1 <= n && r + 1 > n) { st[a].insert(now); } } } } for (auto i:st[b]) { st[a].insert(i); } st[b].clear(); cout << st[a].size() << endl; } signed main(){ AC; int n; cin >> n; string ss; cin >> ss; ss = '?' + ss; FOR (i, 1, n + 1) { string tmp; tmp+=ss[i]; boss[i] = i; st[i].insert(tmp); ans[i] = 1; s[i]+=ss[i]; } FOR (i, 1, n) { int a, b; cin >> a >> b; int fa = find(a), fb = find(b); merge(fa, fb); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 4 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 6 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 12 ms | 340 KB | Output is correct |
7 | Correct | 3 ms | 340 KB | Output is correct |
8 | Correct | 15 ms | 400 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 18 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 4 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 6 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 12 ms | 340 KB | Output is correct |
7 | Correct | 3 ms | 340 KB | Output is correct |
8 | Correct | 15 ms | 400 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 18 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Execution timed out | 1073 ms | 1116 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 1232 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 4 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 6 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 12 ms | 340 KB | Output is correct |
7 | Correct | 3 ms | 340 KB | Output is correct |
8 | Correct | 15 ms | 400 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 18 ms | 340 KB | Output is correct |
11 | Correct | 2 ms | 340 KB | Output is correct |
12 | Correct | 2 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Execution timed out | 1073 ms | 1116 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |