답안 #681922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681922 2023-01-14T21:54:16 Z MilosMilutinovic Tug of War (BOI15_tug) C++14
0 / 100
16 ms 4604 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[N];
int r[N];
int s[N];
vector<int> g[4 * N];
int ver;
int pos;
bool was[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 1 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 4604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 3156 KB Output isn't correct
2 Halted 0 ms 0 KB -