| Task: | Anagrams |
| Sender: | phid |
| Submission time: | 2020-09-26 15:09:44 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.08 s | details |
| #2 | WRONG ANSWER | 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:30:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size() - 1; i++) {
~~^~~~~~~~~~~~~~
input/code.cpp:45:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (i < count.size())
~~^~~~~~~~~~~~~~
input/code.cpp:52:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (count[i] == 0 && i < count.size()) i++;
~~^~~~~~~~~~~~~~Code
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<string, string>> v; // (sorted, orginal)
string st;
for (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;
});
vector<int> count(v.size() + 1, 0);
n = 0;
for (int 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;
int i = 0, s = 0;
while (i < count.size())
{
if (count[i] != 0) i++;
else
{
cout << count[i - 1] << endl;
for (int j = s; j < i; j++) cout << v[j].second << endl;
while (count[i] == 0 && i < count.size()) i++;
s = i;
}
}
return 0;
}Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 68760 aakkonen aakkosellinen aakkosellisesti aakkosellisuus ... |
| correct output |
|---|
| 3076 2 haaraantua raahaantua 2 ... |
| user output |
|---|
| 3076 0 2 raahaantua haaraantua ... Truncated |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 370099 a aa aaa aah ... |
| correct output |
|---|
| 30178 2 basiparachromatin marsipobranchiata 2 ... |
| user output |
|---|
| 30178 0 2 basiparachromatin marsipobranchiata ... Truncated |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 100000 cnhmuewgnum dxkmhzhetnmxadtcy hfjqwavsiguwpludsketibe xwxolrmvkz ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 0 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 400000 vlcsa eltwde wdcwwkubs tmuxbirj ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 0 |
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 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 0 |
