QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#73692 | #3873. Towers | YeongTree | 0 | 794ms | 113764kb | C++20 | 2.1kb | 2023-01-27 16:27:53 | 2023-01-27 16:27:54 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <functional>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define plll pair<long long, pll>
#define tiii tuple<int, int, int>
#define tiiii tuple<int, int, int, int>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
const int INF = (int)1e9 + 7;
using namespace std;
const int MAXN = 1'000'005;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
pii A[n]; for(auto &i : A) cin >> i.ff >> i.ss;
vector<int> yls[MAXN];
for(int i = 0; i < n; ++i) yls[A[i].ss].push_back(i);
vector<int> xls[MAXN];
for(int i = 0; i < MAXN; ++i) for(auto j : yls[i]) xls[A[j].ff].push_back(j);
pii xl[MAXN], yl[MAXN];
fill(xl, xl + MAXN, pii{-1, -1});
fill(yl, yl + MAXN, pii{-1, -1});
string s(n, '0');
function<void(int)> f = [&](int i)
{
int y = A[i].ss;
s[i] = '1';
if(yl[y].ff == -1) yl[y].ff = i;
else if(yl[y].ss == -1) yl[y].ss = i;
else
{
int B[3] = { yl[y].ff, yl[y].ss, i };
sort(B, B + 3, [&](int x, int y){ return A[x].ff < A[y].ff; });
yl[y].ff = B[0];
yl[y].ss = B[2];
i = B[1];
s[i] = '0';
if(xl[A[i].ff].ff == xl[A[i].ss].ss) xl[A[i].ff].ff = xl[A[i].ff].ss = -1;
else
{
if(xls[A[i].ff][xl[A[i].ff].ff] == i) if(++xl[A[i].ff].ff != xl[A[i].ff].ss) f(xls[A[i].ff][xl[A[i].ff].ff]);
else if(--xl[A[i].ff].ss == xl[A[i].ff].ff) f(xls[A[i].ff][xl[A[i].ff].ss]);
}
}
};
for(int i = 0; i < MAXN; ++i) if(xls[i].size())
{
if(xls[i].size() == 1)
{
xl[i].ff = xl[i].ss = 0;
f(xls[i][0]);
}
else
{
xl[i].ff = 0;
f(xls[i][0]);
xl[i].ss = (int)xls[i].size() - 1;
f(xls[i].back());
}
}
cout << s;
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 5
Accepted
time: 38ms
memory: 65836kb
input:
2 869400 218695 664808 31410
output:
11
result:
ok
Test #2:
score: 0
Accepted
time: 19ms
memory: 65832kb
input:
2 195447 154323 271823 133730
output:
11
result:
ok
Test #3:
score: 0
Accepted
time: 21ms
memory: 65892kb
input:
3 751594 545975 951568 859051 621150 686048
output:
111
result:
ok
Test #4:
score: 0
Accepted
time: 31ms
memory: 65860kb
input:
3 404592 259430 770816 43371 147329 582162
output:
111
result:
ok
Test #5:
score: 0
Accepted
time: 25ms
memory: 65940kb
input:
3 401670 296316 401670 809250 401670 595959
output:
110
result:
ok
Test #6:
score: 0
Accepted
time: 16ms
memory: 65844kb
input:
3 657802 927690 657802 872623 657802 83083
output:
101
result:
ok
Test #7:
score: 0
Accepted
time: 26ms
memory: 65836kb
input:
3 759291 185618 759291 386687 759291 100713
output:
011
result:
ok
Test #8:
score: -5
Runtime Error
input:
3 997737 106763 684497 106763 412296 106763
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #26:
score: 0
Wrong Answer
time: 33ms
memory: 67824kb
input:
92690 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 6...
output:
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
wrong answer
Subtask #4:
score: 0
Runtime Error
Test #38:
score: 0
Runtime Error
input:
1000000 1 18543 4 40327 7 19084 8 44274 10 42366 12 22173 13 9862 15 44706 19 48070 21 13389 24 39273 26 18680 27 46858 28 46126 32 27753 34 28289 36 12220 38 39235 42 28505 45 47348 46 34220 48 47551 50 49156 54 8856 55 25515 56 21932 58 24482 59 20686 61 41381 66 30112 67 44504 70 24510 71 26418 7...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Wrong Answer
Test #85:
score: 0
Wrong Answer
time: 794ms
memory: 113764kb
input:
1000000 1 602300 1 778881 2 397065 3 291452 3 678039 5 235300 6 499367 8 8597 10 327718 10 516489 12 416542 12 440048 13 284169 13 383581 13 642202 13 770858 14 378154 14 710033 15 905531 16 50155 17 142259 19 395613 19 500321 20 358934 21 461772 24 562953 24 995887 25 421244 27 900412 29 301006 31 ...
output:
001111111111100111111111111111101011110111101101111111111111111111111111111111111101111110111111111111110011111011111111111111111111111001111011111001100111101111111111000111111111111111000111111111101111111011111111111111110111111111111111111101111111110111111111011111111111111111111111110110011111...
result:
wrong answer