답안 #1041455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041455 2024-08-02T04:08:16 Z hotboy2703 조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2) C++17
0 / 100
1 ms 348 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++;
            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++;
                                }
                            }
                        }
                    }
                }
            }
        }  
        cout<<ans<<'\n'; 
    }
    // dnc(0,n,all);
    // for (ll i = 1;i <= cnt;i ++)cout<<ans[i].fi<<' '<<ans[i].se<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -