이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")
const int N = 2e6+6;
int32_t main()
{
int n, k;
cin >> n >> k;
int l[n*2], r[n*2], s[2*n];
for (int i = 0 ;i < 2*n; i++)
cin >> l[i] >> r[i] >> s[i];
for (int i = 0; i < (1 << (2*n)); i++)
{
int x[2*n];
int kk = i;
for (int j = 0; j < 2*n; j++)
x[j] = kk % 2, kk /= 2;
set<int> s1,s2;
int sum1 = 0, sum2 = 0;
for (int j = 0; j < 2*n; j++)
{
if (x[j] == 1)
s1.insert(l[j]), sum1 += s[j];
else
s2.insert(r[j]), sum2 += s[j];
}
if (s1.size() == n && s2.size() == n && abs(sum1 - sum2) <= k)
{
cout << "YES";
return 0;
}
}
cout << "NO";
}
컴파일 시 표준 에러 (stderr) 메시지
tug.cpp: In function 'int32_t main()':
tug.cpp:39:23: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
39 | if (s1.size() == n && s2.size() == n && abs(sum1 - sum2) <= k)
| ~~~~~~~~~~^~~~
tug.cpp:39:41: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
39 | if (s1.size() == n && s2.size() == n && abs(sum1 - sum2) <= k)
| ~~~~~~~~~~^~~~
# | 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... |