# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
704991 | 2023-03-03T07:40:14 Z | Paul_Liao_1457 | Palindromi (COCI22_palindromi) | C++17 | 62 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; ans[a]+=ans[b]; s[a]+=s[b]; FOR(mid, 0, s[a].size()) { int len = 1; while (mid - len >= 0 && mid + len < s[a].size() && s[a][mid-len] == s[a][mid+len]) { len++; } if (mid - len + 1 <= n && mid + len + 1 > n) { ans[a]++; } } for (auto i:st[b]) { st[a].insert(i); } cout << ans[a] << endl; } signed main(){ AC; int n; cin >> n; string ss; cin >> ss; ss = '?' + ss; FOR (i, 1, n + 1) { boss[i] = i; st[i].insert(s[i]); ans[i] = 1; } FOR (i, 1, n) { int a, b; cin >> a >> b; int fa = find(a), fb = find(b); merge(fa, fb); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 62 ms | 1232 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |