Submission #624032

# Submission time Handle Problem Language Result Execution time Memory
624032 2022-08-07T07:04:56 Z radal Making Friends on Joitter is Fun (JOI20_joitter2) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,avx2")
#pragma GCC optimize("unroll-loops,O2")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pll;
constexpr int N = 50+10,mod = 998244353,inf = 1e9+10,sq = 700;
inline int mkay(int a,int b){
    if (a+b >= mod) return a+b-mod;
    if (a+b < 0) return a+b+mod;
    return a+b;
}
 
inline int poww(int a,int k){
    if (k < 0) return 0;
    int z = 1;
    while (k){
        if (k&1) z = 1ll*z*a%mod;
        a = 1ll*a*a%mod;
        k /= 2;
    } 
    return z; 
}
int a[N][N];
int main(){
    ios :: sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin >> n >> m;
    ll ans = 0;
    while (m--){
        int u,v;
        cin >> u >> v;
        if (a[u][v] == 1){
            cout << ans << endl;
            continue;
        }
        a[u][v] = 1;
        bool f = 1;
        ans++;
        while (f){
            f = 0;
            rep(x,1,n+1){
                rep(y,1,n+1){
                    if (!a[x][y] || !a[y][x]) continue;
                    rep(z,1,n+1){
                        if (a[z][y] || !a[z][x]) continue;
                        a[z][y] = 1;
                        f = 1;
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -