CSES - Aalto Competitive Programming 2024 - wk8 - Mon - Results
Submission details
Task:Illuminati
Sender:eyong002
Submission time:2024-10-28 17:40:16 +0200
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#10.16 sdetails
#20.16 sdetails
#30.16 sdetails
#40.16 sdetails
#50.16 sdetails
#60.16 sdetails
#70.16 sdetails
#80.16 sdetails
#90.16 sdetails
#100.15 sdetails
#110.16 sdetails
#120.16 sdetails
#130.16 sdetails
#140.15 sdetails
#150.16 sdetails
#160.16 sdetails
#170.16 sdetails
#180.16 sdetails
#190.15 sdetails
#200.16 sdetails
#210.16 sdetails
#220.16 sdetails
#230.15 sdetails
#240.16 sdetails
#250.16 sdetails
#260.16 sdetails
#270.16 sdetails
#280.16 sdetails
#290.16 sdetails
#300.16 sdetails
#310.16 sdetails
#320.16 sdetails
#330.15 sdetails
#340.16 sdetails
#350.16 sdetails
#360.16 sdetails
#370.16 sdetails
#380.16 sdetails
#390.16 sdetails
#400.16 sdetails
#410.16 sdetails
#420.16 sdetails
#430.16 sdetails
#440.16 sdetails
#450.16 sdetails
#460.16 sdetails
#470.16 sdetails
#48--details
#49--details
#50--details
#51--details
#52--details
#53--details

Code

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define V 3000
int n;

void multiply(int A[][V], int B[][V], int C[][V])
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			C[i][j] = 0;
			for (int k = 0; k < n; k++)
				C[i][j] += A[i][k]*B[k][j];
		}
	}
}

int getTrace(int graph[][V])
{
	int trace = 0;
	for (int i = 0; i < V; i++)
		trace += graph[i][i];
	return trace;
}

int triangleInGraph(int graph[][V])
{
	int aux2[V][V];

	int aux3[V][V];

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			aux2[i][j] = aux3[i][j] = 0;

	multiply(graph, graph, aux2);

	multiply(graph, aux2, aux3);

	int trace = getTrace(aux3);
	return trace / 6;
}

signed main()
{
    cin >> n;
	int graph[V][V] = {0};
	
	for (int i = 0; i < n; i++){
	    string temp;
	    cin >> temp;
	    for (int j = 0; j < n; j++){
	        graph[i][j] = temp[j]-'0';
	        //cout << graph[i][j];
	    }
	}

	cout << triangleInGraph(graph);
	return 0;
}

Test details

Test 1

Verdict:

input
1
0

correct output
0

user output
12025236505029397

Test 2

Verdict:

input
2
01
10

correct output
0

user output
12025236505029397

Test 3

Verdict:

input
2
01
10

correct output
0

user output
12025236505029397

Test 4

Verdict:

input
3
011
101
110

correct output
1

user output
12025236505029398

Test 5

Verdict:

input
3
010
101
010

correct output
0

user output
12025236505029397

Test 6

Verdict:

input
3
000
001
010

correct output
0

user output
12025236505029397

Test 7

Verdict:

input
3
011
100
100

correct output
0

user output
12025236505029397

Test 8

Verdict:

input
4
0111
1011
1101
1110

correct output
4

user output
12025236505029401

Test 9

Verdict:

input
4
0011
0010
1100
1000

correct output
0

user output
12025236505029397

Test 10

Verdict:

input
4
0000
0011
0101
0110

correct output
1

user output
12025236505029398

Test 11

Verdict:

input
4
0101
1010
0100
1000

correct output
0

user output
12025236505029397

Test 12

Verdict:

input
4
0111
1001
1001
1110

correct output
2

user output
12025236505029399

Test 13

Verdict:

input
4
0001
0010
0100
1000

correct output
0

user output
12025236505029397

Test 14

Verdict:

input
4
0110
1001
1000
0100

correct output
0

user output
12025236505029397

Test 15

Verdict:

input
4
0001
0000
0001
1010

correct output
0

user output
12025236505029397

Test 16

Verdict:

input
4
0101
1001
0000
1100

correct output
1

user output
12025236505029398

Test 17

Verdict:

input
4
0001
0000
0000
1000

correct output
0

user output
12025236505029397

Test 18

Verdict:

input
5
01111
10111
11010
11101
...

correct output
7

user output
12025236505029404

Test 19

Verdict:

input
5
00111
00000
10010
10100
...

correct output
1

user output
12025236505029398

Test 20

Verdict:

input
5
00001
00110
01000
01000
...

correct output
0

user output
12025236505029397

Test 21

Verdict:

input
5
01011
10001
00011
10100
...

correct output
1

user output
12025236505029398

Test 22

Verdict:

input
5
01110
10111
11011
11101
...

correct output
7

user output
12025236505029404

Test 23

Verdict:

input
5
00011
00001
00010
10100
...

correct output
0

user output
12025236505029397

Test 24

Verdict:

input
5
01100
10100
11000
00001
...

correct output
1

user output
12025236505029398

Test 25

Verdict:

input
5
00010
00011
00001
11000
...

correct output
0

user output
12025236505029397

Test 26

Verdict:

input
5
01010
10101
01010
10100
...

correct output
0

user output
12025236505029397

Test 27

Verdict:

input
5
00010
00000
00000
10000
...

correct output
0

user output
12025236505029397

Test 28

Verdict:

input
10
0111111110
1011000101
1100001110
1100101100
...

correct output
26

user output
12025236505029423

Test 29

Verdict:

input
10
0011100010
0000000010
1001110011
1010001001
...

correct output
11

user output
12025236505029408

Test 30

Verdict:

input
10
0000111000
0000001100
0000011111
0000001101
...

correct output
7

user output
12025236505029404

Test 31

Verdict:

input
10
0101100111
1001000000
0000010000
1100100010
...

correct output
9

user output
12025236505029406

Test 32

Verdict:

input
10
0111011111
1010010010
1101011001
1010101100
...

correct output
22

user output
12025236505029419

Test 33

Verdict:

input
10
0001100110
0001010100
0001010111
1110000110
...

correct output
11

user output
12025236505029408

Test 34

Verdict:

input
10
0110010000
1011011010
1100110110
0100101011
...

correct output
22

user output
12025236505029419

Test 35

Verdict:

input
10
0001001101
0001010000
0000011110
1100000101
...

correct output
13

user output
12025236505029410

Test 36

Verdict:

input
10
0101010110
1000101001
0001011011
1010101110
...

correct output
8

user output
12025236505029405

Test 37

Verdict:

input
10
0001000000
0000100000
0000000010
1000110111
...

correct output
19

user output
12025236505029416

Test 38

Verdict:

input
100
011111111011000101000111010110...

correct output
20807

user output
23456236079185

Test 39

Verdict:

input
100
001110001000000010111001100100...

correct output
21100

user output
23456236079478

Test 40

Verdict:

input
100
000011100000001100001111100110...

correct output
18556

user output
23456236076934

Test 41

Verdict:

input
100
010110011101000000001000010001...

correct output
20091

user output
23456236078469

Test 42

Verdict:

input
100
011101111110010010101100110110...

correct output
21281

user output
23456236079659

Test 43

Verdict:

input
100
000110011001010100101011100011...

correct output
20746

user output
23456236079124

Test 44

Verdict:

input
100
011001000011011010011011010101...

correct output
21793

user output
23456236080171

Test 45

Verdict:

input
100
000100110101010000001111000010...

correct output
19781

user output
23456236078159

Test 46

Verdict:

input
100
010101011000101001101101110111...

correct output
20006

user output
23456236078384

Test 47

Verdict:

input
100
000100000000100000000001011011...

correct output
19161

user output
23456236077539

Test 48

Verdict:

input
1000
011111111011000101000111010110...

correct output
20823418

user output
(empty)

Test 49

Verdict:

input
1000
001110001000000010111001100100...

correct output
20848491

user output
(empty)

Test 50

Verdict:

input
2000
010001011010001100000111100111...

correct output
166808034

user output
(empty)

Test 51

Verdict:

input
2000
000010011000001011011110111110...

correct output
165842024

user output
(empty)

Test 52

Verdict:

input
2999
000110011001010001100011110110...

correct output
561389670

user output
(empty)

Test 53

Verdict:

input
3000
011111111111111111111111111111...

correct output
4495501000

user output
(empty)