Submission #21269316
Source Code Expand
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;
int main()
{
int n, d;
cin >> n >> d;
vector<ll> x(n);
vector<ll> y(n);
for (int i = 0; i < n; i++){
cin >> x[i] >> y[i];
}
two_sat ts(n);
for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
if (abs(x[i] - x[j]) < d){
ts.add_clause(i, false, j, false);
}
if (abs(y[i] - x[j]) < d){
ts.add_clause(i, true, j, false);
}
if (abs(x[i] - y[j]) < d){
ts.add_clause(i, false, j, true);
}
if (abs(y[i] - y[j]) < d){
ts.add_clause(i, true, j, true);
}
}
}
if (!ts.satisfiable()){
cout << "No" << endl;
return 0;
}
cout << "Yes" << endl;
auto answer = ts.answer();
for (int i = 0; i < n; i++){
if (answer[i])
cout << x[i] << endl;
else
cout << y[i] << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | H - Two SAT |
| User | unnohideyuki |
| Language | C++ (GCC 9.2.1) |
| Score | 100 |
| Code Size | 1034 Byte |
| Status | AC |
| Exec Time | 16 ms |
| Memory | 3712 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 100 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 7 ms | 3476 KiB |
| 00-sample-02.txt | AC | 2 ms | 3424 KiB |
| 01-01.txt | AC | 2 ms | 3424 KiB |
| 01-02.txt | AC | 4 ms | 3604 KiB |
| 01-03.txt | AC | 5 ms | 3660 KiB |
| 01-04.txt | AC | 7 ms | 3444 KiB |
| 01-05.txt | AC | 7 ms | 3492 KiB |
| 01-06.txt | AC | 7 ms | 3572 KiB |
| 01-07.txt | AC | 3 ms | 3440 KiB |
| 01-08.txt | AC | 11 ms | 3644 KiB |
| 01-09.txt | AC | 7 ms | 3684 KiB |
| 01-10.txt | AC | 3 ms | 3424 KiB |
| 01-11.txt | AC | 6 ms | 3644 KiB |
| 01-12.txt | AC | 11 ms | 3588 KiB |
| 01-13.txt | AC | 6 ms | 3524 KiB |
| 01-14.txt | AC | 10 ms | 3516 KiB |
| 01-15.txt | AC | 7 ms | 3640 KiB |
| 01-16.txt | AC | 11 ms | 3516 KiB |
| 01-17.txt | AC | 7 ms | 3712 KiB |
| 01-18.txt | AC | 15 ms | 3592 KiB |
| 01-19.txt | AC | 8 ms | 3580 KiB |
| 01-20.txt | AC | 16 ms | 3512 KiB |
| 01-21.txt | AC | 7 ms | 3500 KiB |