답안 #681923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681923 2023-01-14T21:55:50 Z MilosMilutinovic Tug of War (BOI15_tug) C++14
23 / 100
15 ms 5052 KB
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
using namespace std;

typedef long long ll;

const int N = 30333;
int n, k;
int l[2 * N];
int r[2 * N];
int s[2 * N];
vector<int> g[4 * N];
int ver;
int pos;
bool was[4 * N];

void addEdge(int v, int u) {
	g[v].push_back(u);
	g[u].push_back(v);
}

void dfs(int v) {
	if (v < 2 * n)
		ver++;
	else
		pos++;
	was[v] = true;
	for (int u : g[v])
		if (!was[u])
			dfs(u);
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	assert(k >= 0);
	for (int i = 0; i < 2 * n; i++) {
		scanf("%d%d%d", &l[i], &r[i], &s[i]);
		--l[i];--r[i];
		addEdge(i, 2 * n + l[i]);
		addEdge(i, 3 * n + r[i]);
	}
	for (int i = 0; i < 2 * n; i++) if (!was[i]) {
		ver = 0;
		pos = 0;
		dfs(i);
		if (ver > pos) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");

	return 0;
}

Compilation message

tug.cpp: In function 'int main()':
tug.cpp:56:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
tug.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |   scanf("%d%d%d", &l[i], &r[i], &s[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 4564 KB Output is correct
2 Correct 10 ms 4840 KB Output is correct
3 Correct 11 ms 4892 KB Output is correct
4 Correct 10 ms 4820 KB Output is correct
5 Correct 12 ms 4840 KB Output is correct
6 Correct 10 ms 4820 KB Output is correct
7 Correct 11 ms 4920 KB Output is correct
8 Correct 13 ms 4820 KB Output is correct
9 Correct 13 ms 4820 KB Output is correct
10 Correct 12 ms 4796 KB Output is correct
11 Correct 15 ms 4820 KB Output is correct
12 Correct 10 ms 4820 KB Output is correct
13 Correct 11 ms 4892 KB Output is correct
14 Correct 11 ms 4908 KB Output is correct
15 Correct 10 ms 4820 KB Output is correct
16 Correct 10 ms 4840 KB Output is correct
17 Correct 12 ms 4856 KB Output is correct
18 Correct 11 ms 4896 KB Output is correct
19 Correct 10 ms 4820 KB Output is correct
20 Correct 11 ms 4820 KB Output is correct
21 Correct 13 ms 5052 KB Output is correct
22 Correct 11 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -