QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#238796 | #6567. Repetitive String Invention | peddap# | TL | 1032ms | 6036kb | C++14 | 1.3kb | 2023-11-04 17:34:22 | 2023-11-04 17:34:23 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vi vector
using namespace std;
inline bool check(string s)
{
if (s.size()%2!=0) return false;
int mid = s.size()/2;
for (int i=0;i<mid;i++)
{
if (s[i]!=s[i+mid]) return false;
}
return true;
}
int32_t main() {
string s;
cin>>s;
int n = s.size();
map<string, vector<pair<int, int>>> mp;
for (int i=0;i<n;i++)
{
for (int j=i;j<n;j++)
{
string tmp = s.substr(i, j-i+1);
mp[tmp].push_back({i, j});
}
}
int res = 0;
for (auto elem1: mp)
{
for (auto elem2: mp)
{
if (check(elem1.first+elem2.first))
{
auto v1 = elem1.second;
auto v2 = elem2.second;
res+=v1.size()*v2.size();
for (int i=0;i<v1.size();i++)
{
auto val1 = v1[i];
for (int j=0;j<v2.size();j++)
{
auto val2 = v2[j];
if (val2.first<=val1.second) res--;
}
}
}
}
}
cout<<res<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
aaaa
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
axabxbcxcdxd
output:
22
result:
ok single line: '22'
Test #3:
score: 0
Accepted
time: 1032ms
memory: 5896kb
input:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
536006700
result:
ok single line: '536006700'
Test #4:
score: 0
Accepted
time: 387ms
memory: 6036kb
input:
abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab...
output:
136016600
result:
ok single line: '136016600'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
a
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
ab
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
aa
output:
1
result:
ok single line: '1'
Test #8:
score: -100
Time Limit Exceeded
input:
bbbbbrrrrbrbrrbrbrbrbbrrbbbbrrbrrbrbrbrrrrrbbbrrbrrbbrrrbbbbbrrrrbbrbbrrrrrbbrrrbbbbbrbbrbbbrbrrbrrrrrrrrbbrbrbbrrrrrrbbbbbrbrrrrbrrbbrbrrrrrbrbrbbrbrrbrrrrbrbbrbrrbrrbbbbrrrrrbrbbrbbrrrrrbrbrbrbbbrrrrrrrbbbbbbrrbrbrrrrrbbbrbrrrrbbbbrrbrrbbbbbbbrbbbbrrrbrbbbrrrrrrbbbbbrbrrbbbbrbrbrrbbrrrbbbrbbbrbbrr...