| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1302417 | machianh | Towers (NOI22_towers) | C++20 | 1 ms | 468 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937_64 rng(time(0));
ll random(ll l, ll r) {
return l + rng() % (r - l + 1);
}
const int MAXN = 5008;
int n;
struct giaolo {
int x, y;
} a[MAXN];
namespace subtask2 {
const int TMP_MAXN = 23;
int c[TMP_MAXN];
bool check() {
return n <= 17;
}
bool check_state() {
unordered_map<int, int> dx, dy;
for(int i = 1; i <= n; i++) {
if(c[i] == 1) {
dx[a[i].x]++;
dy[a[i].y]++;
} else {
bool dong = false, tay = false, nam = false, bac = false;
for(int j = 1; j <= n; j++) {
if(c[j] == 1) {
if(a[j].x < a[i].x && a[i].y == a[j].y) {
tay = true;
}
if(a[j].x > a[i].x && a[i].y == a[j].y) {
dong = true;
}
if(a[j].y < a[i].y && a[i].x == a[j].x) {
nam = true;
}
if(a[j].y > a[i].y && a[i].x == a[j].x) {
bac = true;
}
}
}
if(!((dong && tay) || (nam && bac))) {
return false;
}
}
if(dx[a[i].x] > 2 || dy[a[i].y] > 2) {
return false;
}
}
}
void Try(int i) {
for(int j = 0; j <= 1; j++) {
c[i] = j;
if(i == n) {
if(check_state()) {
for(int i = 1; i <= n; i++) {
cout << c[i];
}
exit(0);
}
} else {
Try(i + 1);
}
}
}
void main_solve() {
Try(1);
}
}
namespace subtask3 {
bool check() {
unordered_map<int, int> dx;
for(int i = 1; i <= n; i++) {
dx[a[i].x]++;
if(dx[a[i].x] > 2) {
return false;
}
}
return true;
}
unordered_map<int, pair<int, int>> dy;
bool ans[MAXN];
void main_solve() {
for(int i = 1; i <= n; i++) {
dy[a[i].x].first = max(dy[a[i].x].first, a[i].y);
dy[a[i].x].second = min(dy[a[i].x].second, a[i].y);
}
for(int i = 1; i <= n; i++) {
if(dy[a[i].x].first == a[i].y) {
ans[i] = true;
}
if(dy[a[i].x].second == a[i].y) {
ans[i] = true;
}
}
for(int i = 1;i <= n; i++) {
cout << ans[i];
}
}
}
int32_t main() {
if(fopen("SLAMP.inp", "r")) {
freopen("SLAMP.inp", "r", stdin);
freopen("SLAMP.out", "w", stdout);
}
cin.tie(0) -> ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n ;i++) {
cin >> a[i].x >> a[i].y;
}
if(subtask2::check()) {
subtask2::main_solve();
} else {
subtask3::main_solve();
}
}
컴파일 시 표준 에러 (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... | ||||
