제출 #94120

#제출 시각아이디문제언어결과실행 시간메모리
94120KastandaTug of War (BOI15_tug)C++11
18 / 100
104 ms6520 KiB
#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) 메시지

tug.cpp: In function 'int main()':
tug.cpp:47:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d", &n, &k);
    ~~~~~^~~~~~~~~~~~~~~~
tug.cpp:49:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
        scanf("%d%d%d", &L[i], &R[i], &A[i]), R[i] += n;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...