# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1170810 | SmuggingSpun | Making Friends on Joitter is Fun (JOI20_joitter2) | C++20 | 1397 ms | 452 KiB |
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
typedef long long ll;
int n, m;
namespace sub1{
void solve(){
vector<ll>g(n, 0), _g;
for(int _ = 0; _ < m; _++){
int u, v;
cin >> u >> v;
g[--u] |= 1LL << --v;
_g = g;
while(true){
bool flag = false;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(1LL << j & _g[i]){
for(int k = 0; k < n; k++){
if(k != i && k != j && (1LL << j & _g[k]) && (1LL << k & _g[j]) && ((_g[i] >> ll(k) & 1LL) == 0)){
_g[i] |= 1LL << k;
flag = true;
}
}
}
}
}
if(!flag){
break;
}
}
int ans = 0;
for(int i = 0; i < n; i++){
ans += __builtin_popcountll(_g[i]);
}
cout << ans << "\n";
}
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> m;
if(n <= 50){
sub1::solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |