QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618742 | #7814. 消消乐 | crazy_monkey | 0 | 63ms | 31756kb | C++14 | 561b | 2024-10-07 09:40:43 | 2024-10-07 09:40:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
int n;
char s[N];
int nxt[N],dp[N];
map<char,vector<int> > mp;
int main()
{
cin >> n;
cin >> s;
for(int i=1;i<=n;i++){
mp[s[i-1]].push_back(i);
}
for(char a='a';a<='z';a++){
for(int i=0;i<mp[a].size();i+=2)
{
nxt[mp[a][i]]=mp[a][i+1];
}
}
memset(dp,0,sizeof dp);
int ans=0;
for(int i=1;i<=n;i++)
{
dp[i]=dp[nxt[i]+1]+1;
if(nxt[i]>0)ans+=dp[i];
}
// for(int i=1;i<=n;i++)
// {
// cout << nxt[i] << " ";
// }
cout << ans+1;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 14496kb
input:
10 aaaaaaaaaa
output:
6
result:
wrong answer 1st lines differ - expected: '25', found: '6'
Test #2:
score: 0
Wrong Answer
time: 3ms
memory: 14824kb
input:
10 ooooppuuhh
output:
6
result:
wrong answer 1st lines differ - expected: '16', found: '6'
Test #3:
score: 0
Wrong Answer
time: 2ms
memory: 14852kb
input:
10 nnppkkppjj
output:
6
result:
wrong answer 1st lines differ - expected: '16', found: '6'
Test #4:
score: 0
Wrong Answer
time: 2ms
memory: 13132kb
input:
10 vvcckkhhqq
output:
6
result:
wrong answer 1st lines differ - expected: '15', found: '6'
Test #5:
score: 0
Wrong Answer
time: 2ms
memory: 15564kb
input:
10 llmmxxoopp
output:
6
result:
wrong answer 1st lines differ - expected: '15', found: '6'
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 14256kb
input:
800 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjddzziiyyyyjjooppiivvppmmooppttnnbbmmaaqqvvkkllyyvvmmjjsswwxxccwweeeekkhhaakkvvffaaiieessmmiibbff...
output:
407
result:
wrong answer 1st lines differ - expected: '38306', found: '407'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 13512kb
input:
800 pffpgppguqqugllgwhhwxjjxpkkpxnnxlkklunnuxiixallayqqyccccjnnjnyynqccqqjjqtuutboobwddwfwwfgvvgwuuwpqqppttpyggysrrsgwwgeddexbbxbssbvbbvbeebweewwkkwwddwnoontddtcddcajjapffptcctkeekboobfjjfvaavpjjpriirlfflnazdsevmozgezlngnhktrllcgorjoollwtqylmmzxfeibnifcebsnnugzluzlizievzxfnlokzodymigextlmyltzbmptyjf...
output:
396
result:
wrong answer 1st lines differ - expected: '27479', found: '396'
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 13996kb
input:
8000 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...
output:
3998
result:
wrong answer 1st lines differ - expected: '3820477', found: '3998'
Test #9:
score: 0
Wrong Answer
time: 0ms
memory: 14548kb
input:
8000 neenbnnbvjjvddddommolrrlzttzqwwqlfflijjiaqqayaayihhiqmmqduudlzzlyzzyannatyytfiifbqqbroorcffcgjjgwhhwoqqopuupdjjdeqqewnnwvwwvpiiprqqrukkuhbbhsiisrqqrxvvxfmmfzkkzjlljimmiazzariirdvvdcuucpaapbaabbaabccccxqqxivvipttpqffqmggmzhhzdaadyxxyhccheddeaiianggnxjjxqssqfaafqllqskksfuufviivozzocwwcznnzfxxfnss...
output:
4014
result:
wrong answer 1st lines differ - expected: '2713693', found: '4014'
Test #10:
score: 0
Wrong Answer
time: 0ms
memory: 14284kb
input:
8000 ivviurrukrrkaccafoofaxxaleelcyycsiisimmifvvfoeeodppdneenqjjqsccsguugonnoyiiymttmcjjcmkkmjwwjieeikeekdbbdolloyvvyolloxiixmaamfnnfzrrzqbbqweewvttvboobbeebcmmcsqqsiyyifddfyvvyvttvvddvejjeeeeeleellzzlzbbzcrrcobbowsswquuqozzoyqqyulluwvvwyxxyxllxwrrwgmmgeppecvvcsiisyvvyukkuyppyryyrhjjhthhtvssvvnnvnee...
output:
4005
result:
wrong answer 1st lines differ - expected: '2721590', found: '4005'
Test #11:
score: 0
Wrong Answer
time: 10ms
memory: 16220kb
input:
200000 tdaatgfvypbdkxdlvttiuksoooxszoqnqvmtznizlqfstlenqrnmdpkmvhmzftporwzvlbpyplrvrkgrpvqxyjcwwpcinilarbaudodadcglszflkzvmmdahgqphqoueltddqlymwpvweslymviccsmhuezesmlwsswgznaofullpxciuezrbkxfnodiglhpyrfcjajyuqzfoxsysgeqrqmvtqysypgaivfetwhmgxngzdvavbkipanoopqftdmntwpxgaljiqrkppywfuspzfgljheckapftjqar...
output:
100016
result:
wrong answer 1st lines differ - expected: '8356', found: '100016'
Test #12:
score: 0
Wrong Answer
time: 7ms
memory: 15636kb
input:
200000 nleqrvpkpopfbstnolidsxrfhivbwbbqbwxmvymzmnwozrbklbuwliccquzhpfjsbxlnkzewvjpjarqmwcpsvovxeynjrgdjxrauincbnjvokawliinjqqulwxxeztpbrotihuiyjjqsxxosragocxbpjmhquczgwfakfaojxslteazikjqkebpcrrggswjiyetkpyvjubhtoounhveftykvetuwqgpddicnarbsigpjytmhcymvapbmkforkaeccsuhmwiuljmvajlztzjghnohlmxnmdehfxnra...
output:
100013
result:
wrong answer 1st lines differ - expected: '8340', found: '100013'
Test #13:
score: 0
Wrong Answer
time: 6ms
memory: 14936kb
input:
200000 abbabbbbbbaababaaabaaaababaaaaaabbababababbabbaaababbbbaabaabbbbbbababaabababbababaabbaabaaaabbbbbaabbbbaababbbabaaababbbbbbbbbbabbbabaabaabaababbbbbbabaabbbbbbbbbbaaabbbbabaabbaababaaabbabbaaabbbbbaaabababaababbaaabbbbababbbbbbaaaabaaaaaaabbbaabbaaaabbabbbbbaabbbbbbbabbaaaabaaabaabbaaaababbb...
output:
100000
result:
wrong answer 1st lines differ - expected: '52315097', found: '100000'
Test #14:
score: 0
Wrong Answer
time: 3ms
memory: 16336kb
input:
200000 aaaababaaaaabbabababbbbabbbbababbabbaabaaabbabbaabaaaaaabaaaabbbbbbbabaabbabaabababbbaabbbbabbbbbaabaaaabaaaababaaaabbaaaaabbbabbbabbbbbbbaabbbabbaaabbbabaabaaaaaaaaababbaaabbbbaabaabbaaababbabbaabbbbaaababbbbbbbbbbbaabaaabbaaabaabbaaabbabaabbabbaabbbababbaaabaaaaaabbbbbbbabaabbabbaabaabaabaa...
output:
100000
result:
wrong answer 1st lines differ - expected: '72221142', found: '100000'
Test #15:
score: 0
Wrong Answer
time: 9ms
memory: 15932kb
input:
200000 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...
output:
100001
result:
wrong answer 1st lines differ - expected: '2395581278', found: '100001'
Test #16:
score: 0
Wrong Answer
time: 3ms
memory: 15920kb
input:
200000 sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...
output:
100001
result:
wrong answer 1st lines differ - expected: '2396621459', found: '100001'
Test #17:
score: 0
Wrong Answer
time: 3ms
memory: 15508kb
input:
200000 ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...
output:
100001
result:
wrong answer 1st lines differ - expected: '2395864064', found: '100001'
Test #18:
score: 0
Wrong Answer
time: 62ms
memory: 31148kb
input:
2000000 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...
output:
1000001
result:
wrong answer 1st lines differ - expected: '239586659381', found: '1000001'
Test #19:
score: 0
Wrong Answer
time: 59ms
memory: 30424kb
input:
2000000 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
output:
1000001
result:
wrong answer 1st lines differ - expected: '239687303822', found: '1000001'
Test #20:
score: 0
Wrong Answer
time: 63ms
memory: 31756kb
input:
2000000 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...
output:
1000001
result:
wrong answer 1st lines differ - expected: '239608981171', found: '1000001'