| Task: | Illuminati |
| Sender: | hundlij1 |
| Submission time: | 2025-10-27 17:31:50 +0200 |
| Language: | C++ (C++17) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'void task4()':
input/code.cpp:24:19: error: the value of 'n' is not usable in a constant expression
24 | vector<bitset<n>> adj(n);
| ^
input/code.cpp:22:8: note: 'll n' is not const
22 | ll n;
| ^
input/code.cpp:24:19: note: in template argument for type 'long unsigned int'
24 | vector<bitset<n>> adj(n);
| ^
input/code.cpp:24:20: error: template argument 1 is invalid
24 | vector<bitset<n>> adj(n);
| ^~
input/code.cpp:24:20: error: template argument 2 is invalid
input/code.cpp:31:20: error: invalid types 'int[ll {aka long long int}]' for array subscript
31 | adj[i][j] = 1,
| ^
input/code.cpp:32:20: error: invalid types 'int[ll {aka long long int}]' for array subscript
32 | adj[j][i] = 1;
| ^
input/code.cpp:41:19: error: invalid types 'int[int]' for array subsc...Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <climits>
#include <map>
#include <set>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void task4()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
vector<bitset<n>> adj(n);
for(ll i = 0; i < n; i++){
string s;
cin >> s;
for(ll j = 0; j < n; j++){
if(s[j] == '1'){
adj[i][j] = 1,
adj[j][i] = 1;
}
}
}
ll res = 0;
for (int i = 0; i < n;i++){
for (int j = 0; j < n;j++){
if(adj[i][j] == 1 && i != j){
bitset<n> andMatrix = adj[i] & adj[j];
res += andMatrix.count();
}
}
}
cout << res / 6 << endl;
}
ll swaps(vector<ll> &arr) {
vector<ll> nums(arr.begin(), arr.end());
sort(nums.begin(), nums.end());
unordered_map<ll, ll> pos;
for(int i = 0; i < arr.size(); i++){
pos[arr[i]] = i;
}
ll numChanges = 0;
for(ll i = 0; i < arr.size(); i++) {
if(nums[i] != arr[i]) {
ll ind = pos[nums[i]];
swap(arr[i], arr[ind]);
pos[arr[i]] = i;
pos[arr[ind]] = ind;
numChanges++;
}
}
return numChanges;
}
void task3(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> arr(n);
for(ll i = 0; i < n; i++){
cin >> arr[i];
}
cout << swaps(arr) << endl;
}
int main() {
task4();
}
