# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
94120 | Kastanda | Tug of War (BOI15_tug) | C++11 | 104 ms | 6520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 30004, MXN = N * 20;
int n, k, L[N], R[N], A[N], C[MXN];
bool M[N * 2];
set < int > Adj[N * 2];
bitset < MXN > B;
int Brute()
{
int nn = n + n;
vector < int > T[30];
for (int i = 0; i < (1 << nn); i++)
{
for (int j = 1; j <= nn; j++)
T[j].clear();
for (int j = 0; j < nn; j++)
{
int id = j + 1;
if (i >> j & 1)
{
T[L[id]].push_back(id);
}
else
{
T[R[id]].push_back(id);
}
}
int sum = 0, fail = 0;
for (int j = 1; j <= n + n; j++)
{
if (T[j].size() != 1)
{fail = 1; break;}
if (j <= n)
sum += A[T[j][0]];
else
sum -= A[T[j][0]];
}
if (fail == 0 && abs(sum) <= k)
return 1;
}
return 0;
}
int main()
{
scanf("%d%d", &n, &k);
for (int i = 1; i <= n + n; i++)
scanf("%d%d%d", &L[i], &R[i], &A[i]), R[i] += n;
if (Brute())
printf("YES");
else
printf("NO");
return (0);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |