QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140733 | #5159. Justice Served | As3b_team_f_masr# | WA | 337ms | 48872kb | C++14 | 2.0kb | 2023-08-16 18:26:20 | 2023-08-16 18:27:01 |
Judging History
answer
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, 0, 0, 1, -1, 1};
int dj[] = {0, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 1e9 + 7;
const int N = 4e5 + 5, M = 30005;
#define EPS 1e-9
int t, n, m, ans[N], tree[4 * N];
pair<pair<int, int>, int> a[N];
bool cmp(pair<pair<int, int>, int> one, pair<pair<int, int>, int> two) {
if (one.first.first < two.first.first) return true;
if (one.first.first > two.first.first) return false;
if (one.first.second > two.first.second) return true;
return false;
}
void update(int me, int l, int r, int idx, int val) {
if (l == r) {
tree[me] = max(tree[me], val);
return;
}
int m = (l + r) >> 1;
if (idx <= m) update(2 * me, l, m, idx, val);
else update(2 * me + 1, m + 1, r, idx, val);
tree[me] = max(tree[2 * me], tree[2 * me + 1]);
}
int mx(int me, int l, int r, int st, int en) {
if (l > en || r < st) return 0;
if (l >= st && r <= en) return tree[me];
int m = (l + r) >> 1;
return max(mx(2 * me, l, m, st, en), mx(2 * me + 1, m + 1, r, st, en));
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//freopen("output.txt", "w", stdout);
cin >> n;
map<int, int> mp, rev;
int id = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i].first.first >> a[i].first.second, a[i].second = i;
mp[a[i].first.first] = mp[a[i].first.second] = 1;
}
sort(a + 1, a + n + 1, cmp);
for (auto x:mp) rev[x.first] = ++id;
for (int i = 1; i <= n; i++) {
a[i].first.first = rev[a[i].first.first];
a[i].first.second = rev[a[i].first.second];
}
for (int i = 1; i <= n; i++) {
int tmp = mx(1, 1, n, a[i].first.second, N);
ans[a[i].second] = tmp + 1;
update(1, 1, n, a[i].first.second, tmp + 1);
}
for (int i = 1; i <= n; i++) cout << ans[i] - 1 << " ";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5560kb
input:
4 2 8 1 7 4 5 5 2
output:
0 0 1 2
result:
ok single line: '0 0 1 2 '
Test #2:
score: 0
Accepted
time: 1ms
memory: 5580kb
input:
5 2 4 3 3 2 2 4 2 4 1
output:
0 1 1 2 3
result:
ok single line: '0 1 1 2 3 '
Test #3:
score: -100
Wrong Answer
time: 337ms
memory: 48872kb
input:
200000 75760147 173015388 62879760 211229046 6728658 106668560 29476341 129401393 30531505 130450085 39792769 139780734 59486082 221617335 12447225 112582555 94207716 117434450 68962063 193352291 13519090 113644734 60611935 218232526 77901558 166662816 40316254 140281744 39094390 138994435 49921965 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '51062 25770 5 10 10 12 19010 7...59 9 12 84254 91909 88054 9 7 7', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '