QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246685#5159. Justice Servedthanhchauns2#WA 1ms5728kbC++173.5kb2023-11-11 00:14:582023-11-11 00:15:00

Judging History

你现在查看的是最新测评结果

  • [2023-11-11 00:15:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5728kb
  • [2023-11-11 00:14:58]
  • 提交

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 = 1e6 + 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 = -10;
	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;
	}
	n *= 2;
//	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++){
		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 / 2; i++){
		cout << ans[i] << ' ';
	}
}

signed main(){
    cin.tie(0) -> ios::sync_with_stdio(false);
	for (int i = 1, j = 1; i > 0; i--, j++) {
		solve();
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5728kb

input:

4
2 8
1 7
4 5
5 2

output:

1 0 2 3 

result:

wrong answer 1st lines differ - expected: '0 0 1 2', found: '1 0 2 3 '