답안 #873643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873643 2023-11-15T12:21:14 Z vjudge1 Ronald (COCI17_ronald) C++17
105 / 120
32 ms 20816 KB
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#endif
using namespace std;

typedef long long     ll;
typedef pair<int,int> pii;

const int N = 5e5 + 23;
const ll inf = 1e18;

#define F           first
#define S           second
#define pb          push_back
#define kill(x)     cout<<x<<endl, exit(0);
#define all(x)      x.begin(),x.end()
#define sz(x)       (int)x.size()
#define lc          (v << 1)
#define rc          ((v<<1) |1)
#define int         ll

int n,m;
vector<int> G[N];
int sum=0,cnt=0;
bool mark[N];

void dfs(int v) {
	mark[v] = true;
	cnt ++;
	sum += sz(G[v]);
	for(int u : G[v]) {
		if(!mark[u]) dfs(u);
	}
}


int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
	cin>>n>>m;
	for(int i = 0 ; i < m ; i ++) {
		int v,u; cin>>v>>u;
		G[v].pb(u);
		G[u].pb(v);
	}
	bool ok = true;
	for(int i = 1; i<= n ; i++) if(!mark[i]) {
		sum = cnt =0;
		dfs(i);
		ok &= (sum == cnt*(cnt-1));
	}
	cout<<(ok ? "DA" : "NE") << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12380 KB Output is correct
2 Correct 3 ms 12376 KB Output is correct
3 Correct 3 ms 12376 KB Output is correct
4 Correct 3 ms 12380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12376 KB Output is correct
2 Correct 3 ms 12376 KB Output is correct
3 Correct 3 ms 12380 KB Output is correct
4 Correct 3 ms 12508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12376 KB Output is correct
2 Correct 3 ms 12380 KB Output is correct
3 Correct 3 ms 12380 KB Output is correct
4 Correct 3 ms 12380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12380 KB Output is correct
2 Correct 3 ms 12380 KB Output is correct
3 Correct 3 ms 12512 KB Output is correct
4 Correct 3 ms 12472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12376 KB Output is correct
2 Incorrect 3 ms 12380 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12380 KB Output is correct
2 Correct 4 ms 12380 KB Output is correct
3 Correct 3 ms 12380 KB Output is correct
4 Correct 3 ms 12380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 12636 KB Output is correct
2 Correct 11 ms 14620 KB Output is correct
3 Correct 5 ms 13028 KB Output is correct
4 Correct 5 ms 12892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 12720 KB Output is correct
2 Correct 9 ms 14040 KB Output is correct
3 Correct 25 ms 18268 KB Output is correct
4 Correct 32 ms 20816 KB Output is correct