QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#246665 | #5159. Justice Served | thanhchauns2# | WA | 488ms | 63556kb | C++17 | 3.5kb | 2023-11-10 23:55:51 | 2023-11-10 23:55:51 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define rd read()
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define p pair
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
namespace {
typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll;
// istream& operator>>(istream& i, ll &v){ long long t; i >> t; v = t; return i;}
// ostream& operator<<(ostream& out, ll &v){
// vector<long long> x; ll u = v;
// while(u){x.pb(u % 10); u /= 10;}
// reverse(x.begin(), x.end());
// for (auto &o : x){out << o;} return out;
// }
ll read(){ ll x; cin >> x; return x; } ld PI = 3.14159265358979323846; ld eps = 1e-6; ll mod = 1e9 + 7;
template<typename T> void Unique(T &a) {a.erase(unique(a.begin(), a.end()), a.end());}
template<typename T1, typename T2> ostream& operator<<(ostream& out, const p<T1, T2>& x) {return out << x.f << ' ' << x.s;}
template<typename T1, typename T2> istream& operator>>(istream& in, p<T1, T2>& x) {return in >> x.f >> x.s;}
template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {for(auto &x : a) out << x << ' '; return out;};
template<typename T> istream& operator>>(istream& in, deque<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, deque<T>& a) {for(auto &x : a) out << x << ' '; return out;};
template<typename T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template<typename T> using ordered_multiset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;
template<typename T> using pq = priority_queue<T>; template<typename T> using reverse_pq = priority_queue<T, vector<T>, greater<T> >;
template<typename T> using matrix = vector<vector<T> >; template<typename T> using rubik = vector<vector<vector<T> > >;
vector<ll> rdv(int sz) { vector<ll> x(sz); cin >> x;return x; }
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 5;
} // main template
ll ans[N]{}, n, x;
ll TREE[2 * N]{};
void add(ll p, ll value){
for (TREE[p += n] = value; p > 1; p >>= 1) TREE[p>>1] = max(TREE[p], TREE[p^1]);
}
ll query(ll l, ll r){
ll ans = 0;
for (l += n, r += n; l < r; l >>= 1, r >>= 1){
if (l & 1){
ans = max(ans, TREE[l++]);
}
if (r & 1){
ans = max(ans, TREE[--r]);
}
}
return ans;
}
void solve(){
n = rd, x = 1; matrix<ll> C; set<ll> S; map<ll, ll> MM;
for (int i = 0; i < n; i++){
ll f = rd, s = rd; s += f;
C.pb({s, -f, i}); S.insert(f); S.insert(s); // last, -first, index
}
// for (int i = 0; i <= 2 * n; i++){
// TREE[i] = -1;
// }
// cout << C << '\n';
for (auto &o : S){
MM[o] = x++;
}
for (auto &o : C){
o[0] = MM[o[0]];
o[1] = -MM[-o[1]];
}
// cout << C << '\n';
sort(C.rbegin(), C.rend());
for (int i = 0; i < C.size(); i++){
// cout << C[i] << '\n';
ll idx = C[i][2];
ans[idx] = query(0, -C[i][1] + 1) + 1;
add(-C[i][1], ans[idx]);
}
for (int i = 0; i < n; i++){
cout << ans[i] - 1 << ' ';
}
}
signed main(){
cin.tie(0) -> ios::sync_with_stdio(false);
for (int i = 1, j = 1; i > 0; i--, j++) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5680kb
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: 5676kb
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: 488ms
memory: 63556kb
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:
51062 25770 99909 99912 99912 99912 19010 99911 88301 37698 99911 21153 55418 99912 99911 99907 99912 24874 99912 99911 99912 45763 24219 99912 99911 55419 99911 99909 12678 99912 65162 99911 99908 33102 99912 20822 81107 99912 1958 98787 89734 99912 95816 44261 89321 99912 99911 99910 99909 8126 16...
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: '51062 25770 99909 99912 99912 ... 91909 88054 99911 99911 99911 '