Submission #1041457

# Submission time Handle Problem Language Result Execution time Memory
1041457 2024-08-02T04:09:20 Z hotboy2703 Making Friends on Joitter is Fun (JOI20_joitter2) C++17
0 / 100
8 ms 476 KB
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
const ll INF = 1e18;
const ll MAXN = 50;
bool edge[MAXN][MAXN];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    ll n,m;
    cin>>n>>m;
    ll ans = 0;
    for (ll j = 1;j <= m;j ++){
        ll x,y;
        cin>>x>>y;
        if (edge[x][y] == 0){
            edge[x][y] = 1;
            ans++;
            while (1){
                ll pre_ans = ans;
                for (ll x = 1;x <= n;x ++){
                    for (ll y = 1;y <= n;y ++){
                        if (edge[x][y]){
                            for (ll z = 1;z <= n;z ++){
                                if (edge[y][z] && edge[z][y] && z != x){
                                    if (!edge[x][z]){
                                        edge[x][z] = 1;
                                        ans++;
                                    }
                                }
                            }
                        }
                    }
                }
                if (ans==pre_ans)break;
            }
        }  
        cout<<ans<<'\n'; 
    }
    // dnc(0,n,all);
    // for (ll i = 1;i <= cnt;i ++)cout<<ans[i].fi<<' '<<ans[i].se<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Runtime error 8 ms 476 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Runtime error 8 ms 476 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Runtime error 8 ms 476 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -