Submission #51318457
Source Code Expand
Copy
#include<bits/stdc++.h>#define ll long long#define INF 0x3f3f3f3f#define endl '\n'using namespace std;const int N=1e6+233;string s;ll n,f[30],ans;bool flag;int c2n(char ch){return ch - 'a' + 1;}int main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>s;n = s.size();
#include<bits/stdc++.h> #define ll long long #define INF 0x3f3f3f3f #define endl '\n' using namespace std; const int N=1e6+233; string s; ll n,f[30],ans; bool flag; int c2n(char ch){ return ch - 'a' + 1; } int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>s; n = s.size(); for(int i=0;i<n;i++){ int num = c2n(s[i]); f[num] ++; if(f[num] > 1) flag = 1; } for(int i=1;i<=26;i++){ ans += f[i] * (n-f[i]); n -= f[i]; } if(flag) ans++; cout<<ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - One Time Swap |
User | wusixie |
Language | C++ 20 (gcc 12.2) |
Score | 350 |
Code Size | 537 Byte |
Status | AC |
Exec Time | 5 ms |
Memory | 4172 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 350 / 350 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt |
All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 1 ms | 3488 KB |
example_01.txt | AC | 1 ms | 3420 KB |
hand_00.txt | AC | 5 ms | 4040 KB |
hand_01.txt | AC | 1 ms | 3488 KB |
hand_02.txt | AC | 1 ms | 3488 KB |
hand_03.txt | AC | 1 ms | 3376 KB |
hand_04.txt | AC | 1 ms | 3488 KB |
hand_05.txt | AC | 3 ms | 4100 KB |
hand_06.txt | AC | 4 ms | 4100 KB |
random_00.txt | AC | 1 ms | 3360 KB |
random_01.txt | AC | 1 ms | 3480 KB |
random_02.txt | AC | 1 ms | 3420 KB |
random_03.txt | AC | 1 ms | 3448 KB |
random_04.txt | AC | 1 ms | 3556 KB |
random_05.txt | AC | 3 ms | 4172 KB |
random_06.txt | AC | 3 ms | 4092 KB |
random_07.txt | AC | 3 ms | 4092 KB |
random_08.txt | AC | 3 ms | 4108 KB |
random_09.txt | AC | 3 ms | 4116 KB |
random_10.txt | AC | 3 ms | 4064 KB |
random_11.txt | AC | 3 ms | 4064 KB |
random_12.txt | AC | 3 ms | 4116 KB |
random_13.txt | AC | 3 ms | 4092 KB |
random_14.txt | AC | 3 ms | 4088 KB |