CSES - Datatähti 2020 alku - Results
Submission details
Task:Merkkijonot
Sender:kaurip
Submission time:2019-10-01 21:28:22 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.02 s2, 3details
#30.36 s3details
#40.27 s3details
#50.06 s3details
#60.01 s1, 2, 3details
#70.01 s1, 2, 3details
#80.01 s1, 2, 3details
#90.01 s1, 2, 3details
#100.03 s2, 3details
#110.02 s2, 3details
#120.03 s2, 3details
#130.02 s2, 3details
#140.02 s2, 3details
#150.36 s3details
#160.37 s3details
#170.36 s3details
#180.35 s3details
#190.36 s3details
#200.01 s1, 2, 3details
#210.01 s1, 2, 3details
#220.01 s1, 2, 3details
#230.01 s1, 2, 3details
#240.01 s1, 2, 3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(long j = 0; j < strings[i].length(); j++) {
                   ~~^~~~~~~~~~~~~~~~~~~~~

Code

#include <iostream>
#include <unordered_map>
#include <string>

using namespace std;

long long fact(long n) 
{ 
	long long res = 1; 
	for (long i = 2; i <= n; i++) 
		res = res * i; 
	return res; 
}

long long nCr(long n, long r) 
{
	return fact(n) / (fact(r) * fact(n - r)); 
}

int main() {
	long n;
	cin >> n;
	string strings[n];
	for(long i = 0; i < n; i++) {
		cin >> strings[i];
	}
	
	unordered_map<string,long> total;

	for(long i = 0; i < n; i++) {
		unordered_map<char, long> used;
		for(long j = 0; j < strings[i].length(); j++) {
			if(used.count(strings[i][j])) {
				strings[i][j] = used[strings[i][j]];
			} else {
				used[strings[i][j]] = (char)j+48;
				strings[i][j] = (char)j+48;
			}
		}
		if(total.count(strings[i])) {
			total[strings[i]]++;
		} else {
			total[strings[i]] = 1;
		}
	}

	long long pairs = 0;

	for(pair<string,long> entry : total) {
		pairs += nCr(entry.second,2);
		cout << entry.first << ": " << entry.second << endl;
	}

	cout << pairs;

	return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
20
FFDISOVJLPIASANJRBHQXJVW
HBGVRZFWOTAAVUPYKMKXAOBEYUE
JKHXTPHUKTLTLNXMXMSYYFLF
HCSZMXTZCUFHIHSTEWKHCFZRTXU
...

correct output
20

user output
01234567293;<6>??A1CD36A: 1
0123456789:;<=>?;9B62E?4: 1
012345678944<<>?@2>6DE>4: 1
012315

...
Truncated

Test 2

Group: 2, 3

Verdict:

input
5000
AJEDROEDXRGDUSDAPZBXXQBPJ
PDGCTAGCRTBCJICPFELRRMLFD
TISAOTGMDKUCITIEFQVCSBZJYUUO
FMASVJYFPMELSVLQWFZVLVMSPHYL
...

correct output
2178556

user output
01034567599;<=>=1<B7D1F9HBJ1: ...
Truncated

Test 3

Group: 3

Verdict:

input
100000
RESKYADLVRSDCDXJVECAJCAP
CZLIWDHKVNRJHZINHFBOQEPN
LSTRSDTLADUIWXFQJSQPVRSPBCTZ
QEMSZOQSSVBRNQTCLJQIGVQO
...

correct output
404880850

user output
012345613934<=>5@A<<DEFGH<1K: ...
Truncated

Test 4

Group: 3

Verdict:

input
100000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4999950000

user output
(empty)

Test 5

Group: 3

Verdict:

input
100000
IPI
Q
SPGV
UNYE
...

correct output
1041990627

user output
0000: 2
0100: 28
000: 47
0110: 40
0020: 46

Test 6

Group: 1, 2, 3

Verdict:

input
20
A
B
C
D
...

correct output
190

user output
0: 20
190

Test 7

Group: 1, 2, 3

Verdict:

input
1
A

correct output
0

user output
0: 1
0

Test 8

Group: 1, 2, 3

Verdict:

input
20
A
BB
CCC
DDDD
...

correct output
0

user output
0000000000000000000: 1
000000000000000000: 1
0: 1
0000: 1
00000000000000000000: 1
...
Truncated

Test 9

Group: 1, 2, 3

Verdict:

input
2
A
A

correct output
1

user output
0: 2
1

Test 10

Group: 2, 3

Verdict:

input
5000
SEKNHNRHSRFYIHSCDPGXPTGUSYBFKZ...

correct output
20861

user output
0123456789:92: 1
012342628: 1
0123436789:;<0>?:A34A:;4:I4I9M...
Truncated

Test 11

Group: 2, 3

Verdict:

input
5000
UGPWHWOWAREEIROZTRJGUCKDKTZJEO...

correct output
22818

user output
0103456739:;<147@5:7DE4GH537L3...
Truncated

Test 12

Group: 2, 3

Verdict:

input
5000
FFQQCBCINBDWIKHFPO
SCJU
DNHYPGIQNZS
KNQCYRAXHHKORXMOVHL
...

correct output
22268

user output
0123456269:;<=2?4<B?DEF4H?J1B0...
Truncated

Test 13

Group: 2, 3

Verdict:

input
5000
QVWMSYPWXWBBXWCVEOUAVQLDWNBXZB...

correct output
22589

user output
0123456789:1:7>?@00CC7FFH0@58@...
Truncated

Test 14

Group: 2, 3

Verdict:

input
5000
JYORMNQAKXHNRBWGGSMWXWXMBKPBZU...

correct output
20482

user output
0123056779:93==56ABADBF72I5=2M...
Truncated

Test 15

Group: 3

Verdict:

input
100000
DCXXVIEYQAASZJYUUVYZUIJFGVBAYC...

correct output
8925377

user output
0123456589:;<6>09:9C3EFC51JKKM...
Truncated

Test 16

Group: 3

Verdict:

input
100000
IJZHBIYNWQBDWNGZWVXJKXXWFVLPQX...

correct output
8907840

user output
01234567897;;=51@3@C929@: 1
0123443789:;7=>?:: 1
0123456789:0888?@A2CD65GHA72LD...
Truncated

Test 17

Group: 3

Verdict:

input
100000
GWUGLGQDAYGGJROIAKBMMICQMDUQQQ...

correct output
8771809

user output
01234547791;<=;;@0BC3: 1
0123452712:;: 1
01234166892;<=4?@81CDEFGCG?E@0...
Truncated

Test 18

Group: 3

Verdict:

input
100000
SWVSVXURRSLCSHCPAKWESIPCNDKYLD...

correct output
8704480

user output
0123456789:7<29?@AB9D7<: 1
0123403789: 1
0123456731:77=6?=3BC231GH2H:11...
Truncated

Test 19

Group: 3

Verdict:

input
100000
ZLSNSZBGIMCOLPDEAKVDAJCTMBNRLH...

correct output
8672362

user output
01224567897655>908BCD84GH1CDLD...
Truncated

Test 20

Group: 1, 2, 3

Verdict:

input
20
AAB
D
CDBAA
D
...

correct output
15

user output
012: 2
00: 1
0120: 1
01010: 1
0110: 1
...
Truncated

Test 21

Group: 1, 2, 3

Verdict:

input
20
A
CDD
AABBC
DBCB
...

correct output
15

user output
012: 3
01: 2
01224: 1
01031: 1
01130: 1
...
Truncated

Test 22

Group: 1, 2, 3

Verdict:

input
20
ACADD
CDDCD
DACA
CCDCA
...

correct output
17

user output
00222: 1
01114: 1
0003: 1
011: 2
012: 1
...
Truncated

Test 23

Group: 1, 2, 3

Verdict:

input
20
DCDA
BDBA
CACBD
BA
...

correct output
7

user output
00224: 1
0023: 1
010: 1
0100: 1
01230: 1
...
Truncated

Test 24

Group: 1, 2, 3

Verdict:

input
20
DDA
BBCDC
DDD
CCD
...

correct output
14

user output
01010: 1
01230: 1
010: 1
00232: 2
002: 4
...
Truncated