QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#53623 | #4879. Standard Problem | KING_UT# | WA | 2ms | 3636kb | C++20 | 2.2kb | 2022-10-05 15:20:12 | 2022-10-05 15:20:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define repn(i,b) rng(i,1,b+1)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
template<class t>using vc=vector<t>;
#define a first
#define b second
#define eb emplace_back
using vi=vc<int>;
using P=pair<int,int>;
using P1=pair<int,P>;
#define mp make_pair
constexpr int inf = 100000000000000LL;
constexpr int mod = 998244353;
P mrg(P a, P b){
if(a.a < b.a) swap(a, b);
if(a.a > b.a) return a;
return P(a.a, (a.b+b.b)%mod);
}
struct S{
vc<P>seg;
vc<int>lazy;
int B;
void init(int sz){
seg.clear(); lazy.clear();
B=1;
while(B<sz+1) B<<=1;
seg.assign(2*B, P(-inf, 0));
lazy.assign(2*B, 0);
}
void prop(int k){
repn(i,2){
lazy[k*2+i] += lazy[k];
seg[k*2+i].a += lazy[k];
}
lazy[k]=0;
}
P add(int a,int b,int k,int l,int r,int v){
if(a > b or b < l or r < a) return seg[k];
if(a <= l and r <= b){
seg[k].a += v;
lazy[k] += v;
return seg[k];
}
if(lazy[k]) prop(k);
return mrg(add(a,b,k*2+1,l,(l+r)/2,v),add(a,b,k*2+2,(l+r)/2+1,r,v));
}
void add(int a,int b,int v){
add(a,b,0,0,B-1,v);
}
P query(int a,int b,int k,int l,int r){
if(a > b or b < l or r < a) return P(-inf, 0);
if(a <= l and r <= b) return seg[k];
if(lazy[k]) prop(k);
return mrg(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2+1,r));
}
P query(int a,int b){
return query(a,b,0,0,B-1);
}
void setv(int a,int k,int l,int r,P v){
if(l==r){
seg[k] = mrg(seg[k], v);
return;
}
if(lazy[k]) prop(k);
if(a <= (l+r)/2) setv(a,k*2+1,l,(l+r)/2, v);
else setv(a,k*2+2, (l+r)/2+1,r,v);
seg[k] = mrg(seg[k*2+1], seg[k*2+2]);
}
void setv(int a,P v){
setv(a,0,0,B-1,v);
}
}f;
void slv(){
int n,m;cin>>n>>m;
vc<P1>vec;
rep(i,n){
int a,b,c;cin>>a>>b>>c;
vec.eb(c, mp(a, b));
}
f.init(m+1);
f.setv(0, P(0, 1));
rep(i, n){
int cs = vec[i].a;
int le = vec[i].b.a;
int ri = vec[i].b.b;
auto tmp = f.query(0, le-1);
tmp.a += cs;
f.add(le, ri, cs);
f.setv(le, tmp);
}
auto now = f.query(0, m);
cout<<now.a<<" "<<now.b<<'\n';
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int t; cin>>t;
while(t--) slv();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3516kb
input:
2 3 4 1 2 1 2 3 1 2 2 1 2 5 1 4 3 2 5 3
output:
3 1 6 1
result:
ok 4 number(s): "3 1 6 1"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3636kb
input:
30 3 3 1 3 1 1 3 1 1 3 1 3 3 1 2 1 1 3 1 1 3 1 3 3 2 2 1 1 3 1 1 3 1 3 3 1 3 1 1 2 1 1 3 1 3 3 2 3 1 1 2 1 1 3 1 3 3 2 2 1 1 3 1 1 3 1 3 3 2 2 1 1 2 1 1 3 1 3 3 1 3 1 2 3 1 1 3 1 3 3 2 3 1 1 3 1 2 2 1 3 3 1 2 1 1 2 1 1 2 1 3 3 1 3 1 1 3 1 1 3 1 3 3 1 3 1 1 2 1 1 3 1 3 3 2 3 1 1 2 1 1 3 1 3 3 1 3 1 1...
output:
3 1 3 1 3 1 3 1 2 2 3 1 2 2 3 1 3 1 3 1 3 1 3 1 2 2 3 1 2 1 3 1 3 1 2 2 2 2 2 2 3 1 3 1 3 1 3 1 2 1 3 1 3 1 3 1 3 1 3 1
result:
wrong answer 9th numbers differ - expected: '3', found: '2'