CSES - Aalto Competitive Programming 2024 - wk8 - Mon - Results
Submission details
Task:Illuminati
Sender:bubu2006
Submission time:2024-10-28 16:37:19 +0200
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.01 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#33ACCEPTED0.00 sdetails
#34ACCEPTED0.00 sdetails
#35ACCEPTED0.00 sdetails
#36ACCEPTED0.00 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.00 sdetails
#39ACCEPTED0.00 sdetails
#40ACCEPTED0.00 sdetails
#41ACCEPTED0.00 sdetails
#42ACCEPTED0.00 sdetails
#43ACCEPTED0.00 sdetails
#44ACCEPTED0.00 sdetails
#45ACCEPTED0.00 sdetails
#46ACCEPTED0.00 sdetails
#47ACCEPTED0.00 sdetails
#48ACCEPTED0.03 sdetails
#49ACCEPTED0.03 sdetails
#50ACCEPTED0.09 sdetails
#51ACCEPTED0.09 sdetails
#52ACCEPTED0.20 sdetails
#53ACCEPTED0.25 sdetails

Code

#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(const char* s) {
    return to_string((string) s);
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
 
void debug_out() {
    cerr << endl;
}
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 3001;

int n;
bitset<N> a[N];

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit); // RTE if input wrong datatype

    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        reverse(all(s));
        a[i] = bitset<N>(s);
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (!a[i][j] || !a[j][i]) continue;
            ans += (a[i] & a[j]).count();
        }
    }

    cout << ans / 3 << '\n';
}

Test details

Test 1

Verdict: ACCEPTED

input
1
0

correct output
0

user output
0

Test 2

Verdict: ACCEPTED

input
2
01
10

correct output
0

user output
0

Test 3

Verdict: ACCEPTED

input
2
01
10

correct output
0

user output
0

Test 4

Verdict: ACCEPTED

input
3
011
101
110

correct output
1

user output
1

Test 5

Verdict: ACCEPTED

input
3
010
101
010

correct output
0

user output
0

Test 6

Verdict: ACCEPTED

input
3
000
001
010

correct output
0

user output
0

Test 7

Verdict: ACCEPTED

input
3
011
100
100

correct output
0

user output
0

Test 8

Verdict: ACCEPTED

input
4
0111
1011
1101
1110

correct output
4

user output
4

Test 9

Verdict: ACCEPTED

input
4
0011
0010
1100
1000

correct output
0

user output
0

Test 10

Verdict: ACCEPTED

input
4
0000
0011
0101
0110

correct output
1

user output
1

Test 11

Verdict: ACCEPTED

input
4
0101
1010
0100
1000

correct output
0

user output
0

Test 12

Verdict: ACCEPTED

input
4
0111
1001
1001
1110

correct output
2

user output
2

Test 13

Verdict: ACCEPTED

input
4
0001
0010
0100
1000

correct output
0

user output
0

Test 14

Verdict: ACCEPTED

input
4
0110
1001
1000
0100

correct output
0

user output
0

Test 15

Verdict: ACCEPTED

input
4
0001
0000
0001
1010

correct output
0

user output
0

Test 16

Verdict: ACCEPTED

input
4
0101
1001
0000
1100

correct output
1

user output
1

Test 17

Verdict: ACCEPTED

input
4
0001
0000
0000
1000

correct output
0

user output
0

Test 18

Verdict: ACCEPTED

input
5
01111
10111
11010
11101
...

correct output
7

user output
7

Test 19

Verdict: ACCEPTED

input
5
00111
00000
10010
10100
...

correct output
1

user output
1

Test 20

Verdict: ACCEPTED

input
5
00001
00110
01000
01000
...

correct output
0

user output
0

Test 21

Verdict: ACCEPTED

input
5
01011
10001
00011
10100
...

correct output
1

user output
1

Test 22

Verdict: ACCEPTED

input
5
01110
10111
11011
11101
...

correct output
7

user output
7

Test 23

Verdict: ACCEPTED

input
5
00011
00001
00010
10100
...

correct output
0

user output
0

Test 24

Verdict: ACCEPTED

input
5
01100
10100
11000
00001
...

correct output
1

user output
1

Test 25

Verdict: ACCEPTED

input
5
00010
00011
00001
11000
...

correct output
0

user output
0

Test 26

Verdict: ACCEPTED

input
5
01010
10101
01010
10100
...

correct output
0

user output
0

Test 27

Verdict: ACCEPTED

input
5
00010
00000
00000
10000
...

correct output
0

user output
0

Test 28

Verdict: ACCEPTED

input
10
0111111110
1011000101
1100001110
1100101100
...

correct output
26

user output
26

Test 29

Verdict: ACCEPTED

input
10
0011100010
0000000010
1001110011
1010001001
...

correct output
11

user output
11

Test 30

Verdict: ACCEPTED

input
10
0000111000
0000001100
0000011111
0000001101
...

correct output
7

user output
7

Test 31

Verdict: ACCEPTED

input
10
0101100111
1001000000
0000010000
1100100010
...

correct output
9

user output
9

Test 32

Verdict: ACCEPTED

input
10
0111011111
1010010010
1101011001
1010101100
...

correct output
22

user output
22

Test 33

Verdict: ACCEPTED

input
10
0001100110
0001010100
0001010111
1110000110
...

correct output
11

user output
11

Test 34

Verdict: ACCEPTED

input
10
0110010000
1011011010
1100110110
0100101011
...

correct output
22

user output
22

Test 35

Verdict: ACCEPTED

input
10
0001001101
0001010000
0000011110
1100000101
...

correct output
13

user output
13

Test 36

Verdict: ACCEPTED

input
10
0101010110
1000101001
0001011011
1010101110
...

correct output
8

user output
8

Test 37

Verdict: ACCEPTED

input
10
0001000000
0000100000
0000000010
1000110111
...

correct output
19

user output
19

Test 38

Verdict: ACCEPTED

input
100
011111111011000101000111010110...

correct output
20807

user output
20807

Test 39

Verdict: ACCEPTED

input
100
001110001000000010111001100100...

correct output
21100

user output
21100

Test 40

Verdict: ACCEPTED

input
100
000011100000001100001111100110...

correct output
18556

user output
18556

Test 41

Verdict: ACCEPTED

input
100
010110011101000000001000010001...

correct output
20091

user output
20091

Test 42

Verdict: ACCEPTED

input
100
011101111110010010101100110110...

correct output
21281

user output
21281

Test 43

Verdict: ACCEPTED

input
100
000110011001010100101011100011...

correct output
20746

user output
20746

Test 44

Verdict: ACCEPTED

input
100
011001000011011010011011010101...

correct output
21793

user output
21793

Test 45

Verdict: ACCEPTED

input
100
000100110101010000001111000010...

correct output
19781

user output
19781

Test 46

Verdict: ACCEPTED

input
100
010101011000101001101101110111...

correct output
20006

user output
20006

Test 47

Verdict: ACCEPTED

input
100
000100000000100000000001011011...

correct output
19161

user output
19161

Test 48

Verdict: ACCEPTED

input
1000
011111111011000101000111010110...

correct output
20823418

user output
20823418

Test 49

Verdict: ACCEPTED

input
1000
001110001000000010111001100100...

correct output
20848491

user output
20848491

Test 50

Verdict: ACCEPTED

input
2000
010001011010001100000111100111...

correct output
166808034

user output
166808034

Test 51

Verdict: ACCEPTED

input
2000
000010011000001011011110111110...

correct output
165842024

user output
165842024

Test 52

Verdict: ACCEPTED

input
2999
000110011001010001100011110110...

correct output
561389670

user output
561389670

Test 53

Verdict: ACCEPTED

input
3000
011111111111111111111111111111...

correct output
4495501000

user output
4495501000