# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
212710 | BThero | Making Friends on Joitter is Fun (JOI20_joitter2) | C++17 | 22 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define DBG 1
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) if (DBG) cerr << #x << " = " << x << endl;
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int adj[55][55];
int n, m, ans;
void push() {
bool did = 0;
do {
did = 0;
for (int x = 1; x <= n; ++x) {
for (int y = 1; y <= n; ++y) {
if (x != y && adj[x][y]) {
for (int z = 1; z <= n; ++z) {
if (x != z && y != z && adj[y][z] && adj[z][y] && adj[x][z] == 0) {
adj[x][z] = 1;
++ans;
did = 1;
}
}
}
}
}
}
while (did);
}
void solve() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= m; ++i) {
int u, v;
scanf("%d %d", &u, &v);
if (adj[u][v] == 0) {
adj[u][v] = 1;
++ans;
push();
}
printf("%d\n", ans);
}
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
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... |