| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1302514 | CrabCNH | Towers (NOI22_towers) | C++20 | 2095 ms | 6432 KiB |
#include <bits/stdc++.h>
#define task "SLAMP"
#define int long long
#define pii pair <int, int>
#define fi first
#define se second
#define szf sizeof
#define sz(s) (int)((s).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef long double ld;
template <class T> void minimize (T &t, T f) {if (t > f) t = f;}
template <class T> void maximize (T &t, T f) {if (t < f) t = f;}
const int maxN = 2e5 + 5;
const ld Eps = 1e-12;
const int inf = 1e18 + 7;
const int Log = 20;
const int mod = 1e9 + 7;
// mt19937_64 rd (chrono :: steady_clock :: now ().time_since_epoch ().count ());
// int Rand (int l, int r) {return uniform_int_distribution <int> (l, r) (rd);}
int n;
pii a[maxN];
vector <int> posX[maxN], posY[maxN];
vector <int> px, py;
namespace sub2 {
int act[maxN];
bool check () {
for (auto it : px) {
int cnt = 0;
for (auto i : posX[it]) {
cnt += act[i];
}
if (cnt > 2) {
return false;
}
}
for (auto it : py) {
int cnt = 0;
for (auto i : posY[it]) {
cnt += act[i];
}
if (cnt > 2) {
return false;
}
}
for (int i = 1; i <= n; i ++) {
if (act[i] == 1) {
continue;
}
auto [x, y] = a[i];
int ok = 0;
{
int cntL = 0;
int cntR = 0;
for (auto it : posX[x]) {
if (act[it] == 0) {
continue;
}
int yl = a[it].se;
// if (i == 4) {
// cout << yl << ' ' << y << '\n';
// }
if (yl < y) {
cntL ++;
}
else if (yl > y) {
cntR ++;
}
}
// if (i == 4) {
// cout << cntL << ' ' << cntR << '\n';
// }
if (cntL != 0 && cntR != 0) {
ok = 1;
}
}
if (ok) {
continue;
}
{
int cntL = 0;
int cntR = 0;
for (auto it : posY[y]) {
if (act[it] == 0) {
continue;
}
int xl = a[it].fi;
// if (i == 4) {
// cout << xl << ' ' << it << '\n';
// }
if (xl < x) {
cntL ++;
}
else if (xl > x) {
cntR ++;
}
}
// if (i == 4) {
// cout << cntL << ' ' << cntR << '\n';
// }
if (cntL != 0 && cntR != 0) {
ok = 1;
}
}
//cout << i << ' ' << ok << '\n';
if (ok == 0) {
return false;
}
}
return true;
}
void sol () {
// for (int i = 1; i <= n; i ++) {
// char c;
// cin >> c;
// act[i] = (c - '0');
// //cout << act[i] << ' ';
// }
// cout << check ();
// return;
for (int mask = 0; mask < (1 << n); mask ++) {
for (int i = 1; i <= n; i ++) {
act[i] = ((mask >> (i - 1)) & 1);
}
if (check ()) {
for (int i = 1; i <= n; i ++) {
cout << act[i];
}
}
}
}
}
inline void Solve () {
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> a[i].fi >> a[i].se;
}
for (int i = 1; i <= n; i ++) {
posX[a[i].fi].push_back (i);
posY[a[i].se].push_back (i);
px.push_back (a[i].fi);
py.push_back (a[i].se);
}
sort (all (px));
px.erase (unique (all (px)), px.end ());
sort (all (py));
py.erase (unique (all (py)), py.end ());
sub2 :: sol ();
return;
}
signed main () {
cin.tie (nullptr) -> sync_with_stdio (false);
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int t = 1;
//cin >> t;
while (t --) {
Solve ();
}
return 0;
}
// Stress test :
// Check constant :
// Check taskname :
// Check debug :
// Check subtask :
컴파일 시 표준 에러 (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
