Task: | Illuminati |
Sender: | fabiank |
Submission time: | 2024-10-28 17:49:43 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.00 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.01 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.00 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | ACCEPTED | 0.00 s | details |
#33 | ACCEPTED | 0.00 s | details |
#34 | ACCEPTED | 0.00 s | details |
#35 | ACCEPTED | 0.00 s | details |
#36 | ACCEPTED | 0.00 s | details |
#37 | ACCEPTED | 0.00 s | details |
#38 | ACCEPTED | 0.00 s | details |
#39 | ACCEPTED | 0.00 s | details |
#40 | ACCEPTED | 0.00 s | details |
#41 | ACCEPTED | 0.00 s | details |
#42 | ACCEPTED | 0.00 s | details |
#43 | ACCEPTED | 0.00 s | details |
#44 | ACCEPTED | 0.00 s | details |
#45 | ACCEPTED | 0.00 s | details |
#46 | ACCEPTED | 0.01 s | details |
#47 | ACCEPTED | 0.00 s | details |
#48 | ACCEPTED | 0.59 s | details |
#49 | ACCEPTED | 0.59 s | details |
#50 | TIME LIMIT EXCEEDED | -- | details |
#51 | TIME LIMIT EXCEEDED | -- | details |
#52 | TIME LIMIT EXCEEDED | -- | details |
#53 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'long long int ford_fulkerson(std::vector<std::vector<long long int> >&, int, int)': input/code.cpp:137:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 137 | for (int i = 1; i < path_reversed.size(); i++) | ~~^~~~~~~~~~~~~~~~~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:182:23: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 182 | for (int i = 0; i < n; i++) | ~~^~~ input/code.cpp:196:23: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 196 | for (int i = 0; i < n; i++) | ~~^~~ input/code.cpp:198:31: warning: comparison of integer expressions of different signedness: 'int'...
Code
#include <bits/stdc++.h> #define REP(i, a, b) for (int i = a; i < b; i++) // Type Aliases for 1D and 2D vectors with initialization #define vll(n, val) vector<long long>(n, val) // 1D vector of long longs with size n, initialized to val #define ll long long #define vvi(n, m, val) vector<vector<int>>(n, vector<int>(m, val)) // 2D vector of ints (n x m), initialized to val #define vvll(n, m, val) vector<vector<long long>>(n, vector<long long>(m, val)) // 2D vector of long longs (n x m), initialized to val using namespace std; void print_vector(vector<int> &x) { for (int v : x) { cout << v << " "; } cout << "\n"; } void print_matrix(vector<vector<int>> &matrix) { cout << "\n" << "----------------" << "\n"; for (vector<int> row : matrix) { print_vector(row); } cout << "\n" << "----------------" << "\n"; } int calc_max_digit(int n) { int max_digit = 0; while (n > 0 && max_digit < 9) { int digit = n % 10; if (digit > max_digit) { max_digit = digit; } n /= 10; } return max_digit; } // edges as edge list for outgoing node as pairs (end, cost) vector<ll> dijkstras(int start_point, vector<vector<pair<int, int>>> edges) { int n = edges.size(); vector<bool> processed(n, false); vector<ll> distances(n, LLONG_MAX); distances[start_point] = 0; priority_queue<pair<ll, int>> pq; pq.push({0, start_point}); while (!pq.empty()) { int curr = pq.top().second; pq.pop(); if (processed[curr]) { continue; } processed[curr] = true; ll distance = distances[curr]; for (pair<int, int> edge : edges[curr]) { if (distance + edge.second < distances[edge.first]) { distances[edge.first] = distance + edge.second; pq.push({-distances[edge.first], edge.first}); } } } return distances; } int bfs_edmondson_karp(const vector<vector<ll>> &connections, const int source, const int target, vector<int> &path_reversed) { int n = connections.size(); queue<pair<int, ll>> queue; queue.push({source, LLONG_MAX}); vector<int> predecessor(n, -2); predecessor[source] = -1; while (!queue.empty()) { int current = queue.front().first; ll current_bottleneck = queue.front().second; queue.pop(); if (current == target) { while (current != -1) { path_reversed.push_back(current); current = predecessor[current]; } return current_bottleneck; } for (int edge_end = 0; edge_end < n; edge_end++) { ll edge_cap = connections[current][edge_end]; if (edge_cap > 0 && predecessor[edge_end] == -2) { predecessor[edge_end] = current; queue.push({edge_end, min(current_bottleneck, edge_cap)}); } } } return -1; } ll ford_fulkerson(vector<vector<ll>> &residual_graph, const int source, const int target) { ll flow = 0; while (true) { vector<int> path_reversed; int path_capacity = bfs_edmondson_karp(residual_graph, source, target, path_reversed); if (path_capacity < 0) { break; } flow += path_capacity; for (int i = 1; i < path_reversed.size(); i++) { int edge_end = path_reversed[i - 1]; int edge_start = path_reversed[i]; // reduce forwards edge residual_graph[edge_start][edge_end] -= path_capacity; assert(residual_graph[edge_start][edge_end] >= 0); // add to backwards edge residual_graph[edge_end][edge_start] += path_capacity; assert(residual_graph[edge_end][edge_start] >= 0); } } return flow; } bool dfs(int n, const vector<vector<int>> snakes, vector<bool> &visited, vector<int> path, int start, int target) { if (start == target) { path.push_back(target); return true; } for (int i = n; n >= 1; n--) { if (!visited[i] && !snakes[start][i]) { if (dfs(n, snakes, visited, path, i, target)) { path.push_back(start); return true; } } } return false; } int main() { size_t n; cin >> n; int result = 0; vector<bitset<3000>> s(n); for (int i = 0; i < n; i++) { string str; cin >> str; reverse(str.begin(), str.end()); s[i] = bitset<3000>(str); } // for (int i = 0; i < n; i++) // { // string s; // cout << s[i][0] << endl; // } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (s[i][j]) { for (int k = j + 1; k < n; k++) { // cout << i << " - " << j << " - " << k << endl; // cout << s[j][k] << " - " << s[k][i] << "i: " << i << endl; if (s[j][k] && s[k][i]) { // cout << i << " - " << j << " - " << k << endl; result += 1; } } } } } cout << result << endl; }
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: TIME LIMIT EXCEEDED
input |
---|
2000 010001011010001100000111100111... |
correct output |
---|
166808034 |
user output |
---|
(empty) |
Test 51
Verdict: TIME LIMIT EXCEEDED
input |
---|
2000 000010011000001011011110111110... |
correct output |
---|
165842024 |
user output |
---|
(empty) |
Test 52
Verdict: TIME LIMIT EXCEEDED
input |
---|
2999 000110011001010001100011110110... |
correct output |
---|
561389670 |
user output |
---|
(empty) |
Test 53
Verdict: TIME LIMIT EXCEEDED
input |
---|
3000 011111111111111111111111111111... |
correct output |
---|
4495501000 |
user output |
---|
(empty) |