Task: | Anagrams |
Sender: | kkivimaki |
Submission time: | 2020-09-26 13:36:14 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.20 s | details |
#2 | WRONG ANSWER | 1.00 s | details |
#3 | WRONG ANSWER | 0.41 s | details |
#4 | WRONG ANSWER | 1.03 s | details |
#5 | ACCEPTED | 1.01 s | details |
#6 | ACCEPTED | 1.00 s | details |
#7 | ACCEPTED | 0.01 s | details |
#8 | ACCEPTED | 0.01 s | details |
#9 | ACCEPTED | 0.01 s | details |
Code
#include <iostream> #include <vector> #include <algorithm> using namespace std; long long h(std::string s) { long long m = 0; int t = 1000; for (auto c: s) { m += c*t; } return m; } bool comp(string s1, string s2) { return h(s1) < h(s2); } int main() { int n; cin >> n; vector<string> sanat = vector<string>(); for (int i = 0; i < n; i++) { string s; cin >> s; sanat.push_back(s); } sort(sanat.begin(), sanat.end(), comp); long long v0 = h(sanat[0]); int m = 0; int s = 0; for (int i = 1; i < n; i++) { long long v = h(sanat[i]); if (v != v0) { v0 = v; s = 0; } else { if (!s) { s = 1; m += 1; } } } cout << m << endl; v0 = h(sanat[0]); int f = 1; for (int i = 1; i < n; i++) { long long v = h(sanat[i]); if (v != v0) { v0 = v; if (f > 1) { cout << f << endl; for (int j = i - f; j < i; j++) cout << sanat[j] << endl; } f = 1; } else { f += 1; } } if (f > 1) { cout << f << endl; for (int j = n - f; j < n; j++) cout << sanat[j] << endl; } return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
68760 aakkonen aakkosellinen aakkosellisesti aakkosellisuus ... |
correct output |
---|
3076 2 haaraantua raahaantua 2 ... |
user output |
---|
1835 2 ah ha 2 ... Truncated |
Test 2
Verdict: WRONG ANSWER
input |
---|
370099 a aa aaa aah ... |
correct output |
---|
30178 2 basiparachromatin marsipobranchiata 2 ... |
user output |
---|
1944 2 ba ab 3 ... Truncated |
Test 3
Verdict: WRONG ANSWER
input |
---|
100000 cnhmuewgnum dxkmhzhetnmxadtcy hfjqwavsiguwpludsketibe xwxolrmvkz ... |
correct output |
---|
0 |
user output |
---|
3277 2 bb ac 2 ... Truncated |
Test 4
Verdict: WRONG ANSWER
input |
---|
400000 vlcsa eltwde wdcwwkubs tmuxbirj ... |
correct output |
---|
0 |
user output |
---|
1122 2 bb ca 2 ... Truncated |
Test 5
Verdict: ACCEPTED
input |
---|
400000 ebhfigdacjlk aecfdijlhkgb jfekhbidacgl cehajbidfklg ... |
correct output |
---|
1 400000 abcdeighjlfk abcdeiglhfjk abcdfkilejgh ... |
user output |
---|
1 400000 ihdbalcfjgek eblifdcgjhak dkcflgheiajb ... Truncated |
Test 6
Verdict: ACCEPTED
input |
---|
400000 cbaabghadefb hbbgfaeabdac abaedcbgfbha hcfadbbbeaag ... |
correct output |
---|
1 400000 aaabbbcfegdh aaabbbcfghed aaabbbdcgfhe ... |
user output |
---|
1 400000 gbbaadaechbf hgdafacbaebb bbadhfacabge ... Truncated |
Test 7
Verdict: ACCEPTED
input |
---|
1 a |
correct output |
---|
0 |
user output |
---|
0 |
Test 8
Verdict: ACCEPTED
input |
---|
2 ab ba |
correct output |
---|
1 2 ab ba |
user output |
---|
1 2 ab ba |
Test 9
Verdict: ACCEPTED
input |
---|
2 aa ab |
correct output |
---|
0 |
user output |
---|
0 |