CSES - HIIT Open 2017 - Results
Submission details
Task:Grid
Sender:Ace of Spades
Submission time:2017-05-27 11:43:06 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.05 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.04 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.05 sdetails
#9ACCEPTED0.04 sdetails
#10ACCEPTED0.03 sdetails
#11ACCEPTED0.04 sdetails
#12ACCEPTED0.05 sdetails
#13ACCEPTED0.03 sdetails
#14ACCEPTED0.05 sdetails
#15ACCEPTED0.05 sdetails
#16ACCEPTED0.04 sdetails
#17ACCEPTED0.04 sdetails
#18ACCEPTED0.05 sdetails
#19ACCEPTED0.03 sdetails
#20ACCEPTED0.06 sdetails
#21ACCEPTED0.05 sdetails
#22ACCEPTED0.05 sdetails
#23ACCEPTED1.50 sdetails
#24ACCEPTED1.35 sdetails
#25ACCEPTED1.34 sdetails
#26ACCEPTED1.25 sdetails
#27ACCEPTED1.48 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:30:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for (int64_t k = 0; k < rows[i].size(); ++k) {
                                           ^

Code

#include<iostream>
#include<vector>

using namespace std;

int main(void) {
    int64_t n, m;
    cin >> n >> m;

    vector<vector<uint64_t>> rows(n, vector<uint64_t>((m+63)/64));

    for (int64_t i = 0; i < n; ++i) {
	string r;
	cin >> r;
	for (int64_t j = 0; j < (m+63)/64; ++j) {
	    int64_t res = 0;
	    for (int64_t k = 0; k < 64; ++k) {
		if (j*64 + k < m) {
		    res += ((uint64_t)1<<(uint64_t)k) * (r[j*64+k] - '0');
		}
	    }
	    rows[i][j] = res;
	}
    }

    int64_t res = 0;
    for (int64_t i = 0; i < n; ++i) {
	for (int64_t j = i+1; j < n; ++j) {
	    int64_t cnt = 0;
	    for (int64_t k = 0; k < rows[i].size(); ++k) {
		cnt += __builtin_popcountll(rows[i][k] & rows[j][k]);
	    }
	    res += cnt*(cnt-1)/2;
	}
    }
    cout << res << '\n';
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
10 20
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
...

correct output
8379

user output
8379

Test 2

Verdict: ACCEPTED

input
20 10
1111111111
1101111111
1111111111
1111111111
...

correct output
7880

user output
7880

Test 3

Verdict: ACCEPTED

input
10 20
11111111010111111101
11111110011011111111
11111100011111111111
11101111111111111111
...

correct output
5106

user output
5106

Test 4

Verdict: ACCEPTED

input
20 10
1111100111
1111111111
1011111110
1111111111
...

correct output
4563

user output
4563

Test 5

Verdict: ACCEPTED

input
10 20
11011011011111111110
11111010110110110001
11010010111101111010
01111111111110101111
...

correct output
3099

user output
3099

Test 6

Verdict: ACCEPTED

input
20 10
1110111111
1111111111
1101101110
0111110011
...

correct output
2973

user output
2973

Test 7

Verdict: ACCEPTED

input
10 20
01101101111101110101
10011111111111110111
01111101011010110011
10110101110110101011
...

correct output
2581

user output
2581

Test 8

Verdict: ACCEPTED

input
20 10
1110111001
0111001001
1111011011
1111111010
...

correct output
1660

user output
1660

Test 9

Verdict: ACCEPTED

input
10 20
11000000001100011111
11100111101100110110
11001110011110110101
10100001111011001111
...

correct output
1015

user output
1015

Test 10

Verdict: ACCEPTED

input
20 10
1000011001
1101111110
1000111111
1101101010
...

correct output
1135

user output
1135

Test 11

Verdict: ACCEPTED

input
10 20
10000101101101000110
00100010110011011011
11110111110101101011
11101100011101001011
...

correct output
708

user output
708

Test 12

Verdict: ACCEPTED

input
20 10
1000011111
0001001100
0101110110
1111110001
...

correct output
394

user output
394

Test 13

Verdict: ACCEPTED

input
10 20
00010111101111010011
11010001011010010110
10011001011010100011
01100011001000001100
...

correct output
294

user output
294

Test 14

Verdict: ACCEPTED

input
20 10
0011001110
0000001111
1011100000
0000001001
...

correct output
166

user output
166

Test 15

Verdict: ACCEPTED

input
10 20
10011010001011000110
00100000100000000000
00000110001000110001
01000000101100110101
...

correct output
87

user output
87

Test 16

Verdict: ACCEPTED

input
20 10
0000110101
1000000001
0101100110
0100001010
...

correct output
134

user output
134

Test 17

Verdict: ACCEPTED

input
10 20
00000001100001000100
00000100000010000001
00000100000010000010
10000010000000100000
...

correct output
5

user output
5

Test 18

Verdict: ACCEPTED

input
20 10
0100001000
0100000000
0000010001
0000101000
...

correct output
4

user output
4

Test 19

Verdict: ACCEPTED

input
10 20
00100010000100000000
00000000000000000000
00100000000000000000
00000001000000000010
...

correct output
0

user output
0

Test 20

Verdict: ACCEPTED

input
20 10
0000010000
0000000000
1000000000
0000000000
...

correct output
0

user output
0

Test 21

Verdict: ACCEPTED

input
10 20
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
...

correct output
0

user output
0

Test 22

Verdict: ACCEPTED

input
20 10
0000000000
0000000000
0000000000
0000000000
...

correct output
0

user output
0

Test 23

Verdict: ACCEPTED

input
3000 3000
111111111111111111111111111111...

correct output
19444691141193

user output
19444691141193

Test 24

Verdict: ACCEPTED

input
3000 3000
001011111110111101100001111011...

correct output
6150476374242

user output
6150476374242

Test 25

Verdict: ACCEPTED

input
3000 3000
001011000111011110110111111110...

correct output
1213493895016

user output
1213493895016

Test 26

Verdict: ACCEPTED

input
3000 3000
000000001001000010110001000001...

correct output
75998707871

user output
75998707871

Test 27

Verdict: ACCEPTED

input
3000 3000
000000000000000000000000000000...

correct output
0

user output
0