Task: | Anagrams |
Sender: | phid |
Submission time: | 2020-09-26 16:00:13 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | RUNTIME ERROR | 0.08 s | details |
#2 | RUNTIME ERROR | 0.46 s | details |
#3 | ACCEPTED | 0.16 s | details |
#4 | ACCEPTED | 0.37 s | details |
#5 | ACCEPTED | 0.78 s | details |
#6 | ACCEPTED | 0.78 s | details |
#7 | ACCEPTED | 0.01 s | details |
#8 | ACCEPTED | 0.01 s | details |
#9 | ACCEPTED | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:15:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (unsigned int i = 0; i < n; i++) { ~~^~~
Code
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <deque> using namespace std; int main() { int n; cin >> n; vector<pair<string, string>> v; // (sorted, orginal) string st; for (unsigned int i = 0; i < n; i++) { cin >> st; string sttmp = st; sort(sttmp.begin(), sttmp.end()); v.push_back(pair<string, string>(sttmp, st)); } sort(v.begin(), v.end(),[] (const auto &a, const auto &b) { return a.first < b.first; }); deque<int> count(v.size() + 1, 0); n = 0; for (unsigned i = 0; i < v.size() - 1; i++) { if (v[i].first == v[i+1].first) { if (count[i] == 0) { count[i] = 1; n++; } count[i + 1] = count[i] + 1; } } cout << n << endl; if (n > 0) { count.push_front(0); unsigned i = count.size() - 1; while (i > 0) { while (count[i] == 0) i--; cout << count[i] << endl; cout << v[i - 1].second << endl; while (count[i] > count[i-1] && count[i-1] != 0 && i > 0) { cout << v[i - 2].second << endl; i--; } i--; } } return 0; }
Test details
Test 1
Verdict: RUNTIME ERROR
input |
---|
68760 aakkonen aakkosellinen aakkosellisesti aakkosellisuus ... |
correct output |
---|
3076 2 haaraantua raahaantua 2 ... |
user output |
---|
3076 2 pus ups 2 ... Truncated |
Test 2
Verdict: RUNTIME ERROR
input |
---|
370099 a aa aaa aah ... |
correct output |
---|
30178 2 basiparachromatin marsipobranchiata 2 ... |
user output |
---|
30178 2 ux xu 2 ... Truncated |
Test 3
Verdict: ACCEPTED
input |
---|
100000 cnhmuewgnum dxkmhzhetnmxadtcy hfjqwavsiguwpludsketibe xwxolrmvkz ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 4
Verdict: ACCEPTED
input |
---|
400000 vlcsa eltwde wdcwwkubs tmuxbirj ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 5
Verdict: ACCEPTED
input |
---|
400000 ebhfigdacjlk aecfdijlhkgb jfekhbidacgl cehajbidfklg ... |
correct output |
---|
1 400000 abcdeighjlfk abcdeiglhfjk abcdfkilejgh ... |
user output |
---|
1 400000 kgafeihdlbjc hacdikgjlfbe ihebjfcgadkl ... Truncated |
Test 6
Verdict: ACCEPTED
input |
---|
400000 cbaabghadefb hbbgfaeabdac abaedcbgfbha hcfadbbbeaag ... |
correct output |
---|
1 400000 aaabbbcfegdh aaabbbcfghed aaabbbdcgfhe ... |
user output |
---|
1 400000 cgdbehafbaab fhbebbadaacg bbeghcaaadbf ... 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 ba ab |
Test 9
Verdict: ACCEPTED
input |
---|
2 aa ab |
correct output |
---|
0 |
user output |
---|
0 |