QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#446002 | #526. Magic | RaduM | 100 ✓ | 49ms | 33028kb | C++20 | 746b | 2024-06-16 18:53:53 | 2024-06-16 18:53:53 |
Judging History
answer
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
string s;
map < vector <int>, int > mp;
vector <int> val(150, -1);
vector <int> v;
int main()
{
int n,i,j,rez = 0,k = 0;
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
cin.get();
cin >> s;
for(const auto &x : s){
if(val[x] == -1) val[x] = k++;
}
v.assign(k, 0);
mp[vector <int> (k, 0)] = 1;
for(const auto &x : s){
v[val[x]]++;
int m = 1e9;
for(auto &x2 : v) m = min(m, x2);
for(auto &x2 : v) x2 -= m;
mp[v]++;
}
for(const auto &x : mp) rez = (rez + (1LL * x.second * (x.second - 1) / 2)) % mod;
cout << rez;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 0ms
memory: 3844kb
input:
100 SsSsSsSsSsSSssSSsSSssSsSsssssSsSssssSsSSSSsSSSSsSsSssSSSSsSSsssSssSssssSsssSssSsSssssssSSssSSsSSSsSS
output:
440
result:
ok single line: '440'
Test #2:
score: 5
Accepted
time: 0ms
memory: 3632kb
input:
100 XUHzGCBgfsEvaJiOlmjuNwYTcpkPynZtVASQqhMDoeFRKbdLIrgOGBUlECmJHzisvfXaQecMypSjPqRtTDowkZnFNYVAuhUrXosy
output:
3
result:
ok single line: '3'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3548kb
input:
200 xtIxtIxtIxtIxxttxIxxxtIItxIIIxxItItxtIItxIxxtIItxIxIIxItttItxxtItxItxItxItxxIIIxtxtIxxtIIttIItIxIItIxtIxtIxtIxtIxttttxIttxtxIxxtIIxtxIIxIIxxIIttIIIxtxIttxItxxxxItxItxItxItxItxItxtxxtIxttIxIIIItxtIxtIx
output:
402
result:
ok single line: '402'
Test #4:
score: 5
Accepted
time: 1ms
memory: 3812kb
input:
500 mhUMlYtJLIiOkfsBSTodgrDQZWbCnvlJLMhmYItUivdnMgDmUCblrfhTsWoQkOSZBYtDrvbniIhUMmdfLsJgTlCvJLSQlnLZMiDIfQYZSgkTJsbWoOodrBOWCkBtnnmYlDLhTmMSbilsJIUvtUQhdgrvfCLYvkWCYhodtfBgsmJObiDroMkZZQtOSTIIWUBiQbLrDhsgWklCtfoCvMlSdUnmJdhLnTvYYWfUZDbSJgIkZOJminfrZsiBMbODgMoQsQTIlSToLlLmDYtvSLiBMdbBgOmUUJTQdfkvlCWn...
output:
19
result:
ok single line: '19'
Test #5:
score: 5
Accepted
time: 0ms
memory: 3708kb
input:
1000 yzdBsSvHpkyzdBsSvHpkyzdBsSvHpkyzdBsSvHpkyzdBsSvHpkyzdBsSvHpkyzdBsSvHpkyzdBsSvHpkyzdBsSvHpkyzdBsSvHpkpkkkHsHSBsdsvkyyzzSBykpHzskdpvSyBHszkdpvSyBHszkdpvSyBHszkdpvSyBHszkdpvSyBHszkdpvSyBHszpsBpyzdsyHkpyvzzzszkpyyBzySHzkSdvyBspHzkSdvyBspHzkSdvyBspHzkSdvyBspHzkSdvyBspHvpkkSsszddykHzkpzBpBkdHSvszypBk...
output:
3103
result:
ok single line: '3103'
Test #6:
score: 5
Accepted
time: 1ms
memory: 4160kb
input:
2000 MyWnObAVvNzcYqECPmTtJXpwjeIkLixhHKlRguQBsDrdSGaUFZWbnMyAOvVunpeHyhNYczPmCFjLKsEwROxMUWSJtrlgIkqQdTiBGDXaZrjClWIEVxwdibQLntNMKPmvqOYFUzuTepsghJkHASRcyDaLVdiWjMCbrEQNXBnxZGKwlItBHhAFcRpuzzEvGbyNZYvgqVTsTmeqAPkmXDacSYUCJPOZRJinjuxSHsUhraXgBDMFplQtWIwkdeGLyOKVFnbPzchHNYepuyCvAmCLDkZcZkidejaqvumJbVL...
output:
56
result:
ok single line: '56'
Test #7:
score: 5
Accepted
time: 0ms
memory: 3492kb
input:
2000 WRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRRRWWWRRWWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRWRW...
output:
207783
result:
ok single line: '207783'
Test #8:
score: 5
Accepted
time: 0ms
memory: 3620kb
input:
5000 BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...
output:
666340
result:
ok single line: '666340'
Test #9:
score: 5
Accepted
time: 1ms
memory: 3592kb
input:
20000 umumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumumum...
output:
19154645
result:
ok single line: '19154645'
Test #10:
score: 5
Accepted
time: 1ms
memory: 3892kb
input:
50000 mpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmpmp...
output:
86508692
result:
ok single line: '86508692'
Test #11:
score: 5
Accepted
time: 2ms
memory: 3676kb
input:
100000 ElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElE...
output:
513536001
result:
ok single line: '513536001'
Test #12:
score: 5
Accepted
time: 1ms
memory: 3708kb
input:
100000 ElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElE...
output:
499749995
result:
ok single line: '499749995'
Test #13:
score: 5
Accepted
time: 0ms
memory: 3668kb
input:
100000 ElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElElE...
output:
499749995
result:
ok single line: '499749995'
Test #14:
score: 5
Accepted
time: 5ms
memory: 6348kb
input:
10000 IrUwTbhZexXAplmaVfqMOBigvjGHoCQJsYNFDLcnRdyESkPutzbiHhVwAsvZOgqMITmClxDQJpojfFeBaNGUYXrIcRXxSPkETAewrpZnbdyzLutUhvHsVxcCMFlNBoigJQOYDjGImafqXRjdeJrtChDgEdlyUhkvuaENsfLPQSoSAiZBOGZrPRcwYLqkzzTUImMnwHyutnVTbFbpvYymCpaaetgENRdXJgXuoxvNUDDxOVcjELfQGJfihHlqFCsljkIdshMeABrIHiTOgoQsRYVOxZqLoDpFTfSAYm...
output:
100
result:
ok single line: '100'
Test #15:
score: 5
Accepted
time: 2ms
memory: 3712kb
input:
50000 RxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRxNHRx...
output:
25510755
result:
ok single line: '25510755'
Test #16:
score: 5
Accepted
time: 0ms
memory: 3712kb
input:
100000 dFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFExBWcrYPdFE...
output:
39836830
result:
ok single line: '39836830'
Test #17:
score: 5
Accepted
time: 47ms
memory: 33028kb
input:
100000 mXYwpGNxavDJQIysKAeZibMOrkfWdlhcFuHnLTESCjUPqztoBgVRpYNXmwGxQDsJIeAyKavLpWTdjURhuEYbtngiHlfZCqBozFOrkVNMScPgKrEQDltaHdmvUFkXuZeILoWOszMiASTBnbjPchxyqfGwJCRXDapvwxQyYImJVGNYhMbNkdZjPgpuUmBKtfienWHwrOSACFEcqzoTXVLslRisvxbKQaDIeZAGyOJMmCTWzhDRwpLPBVdqJsGXEtUuljxrkFfSYHNcnogQKIayvdbWMlAZerOfkiUuE...
output:
699
result:
ok single line: '699'
Test #18:
score: 5
Accepted
time: 49ms
memory: 32692kb
input:
100000 QeuiySpTEKbUdvBrjgIznkLhXRVoDwJAYGPONWfMFqlZHmCacstxwBzfWNMukAUDvrTEiXjbnYQGpPoVIKgeLRdhyJOSNczmZMwftxlHBCasFWqUdLAlpbcuTokyxturpIKEeiYbqSTXaORQZeDyimvQUsdhnCGJKvSPjEVHgFrBODGgWXNNhcMYoLPjIVJkAwRfznmmROpuTdyKYMETUtlbSdqvIBCCJDusqnUzZwhZbtecxQkapeLriHWlAoxafXsGyFQiMBXzOHVtJVNScnkflNgHLBPhGAuqo...
output:
739
result:
ok single line: '739'
Test #19:
score: 5
Accepted
time: 5ms
memory: 3956kb
input:
100000 gruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZWdVkONqQgruAhpZW...
output:
27619254
result:
ok single line: '27619254'
Test #20:
score: 5
Accepted
time: 6ms
memory: 3792kb
input:
100000 MvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgutjQDXzoMvNUleIZJnpgu...
output:
21636849
result:
ok single line: '21636849'