QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21602#2849. 弗雷兹的玩具商店Mr_Eight#WA 164ms136408kbC++144.1kb2022-03-07 16:18:092022-05-08 03:41:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 03:41:51]
  • 评测
  • 测评结果:WA
  • 用时:164ms
  • 内存:136408kb
  • [2022-03-07 16:18:09]
  • 提交

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
//#pra gma G CC opti mize(3)
using namespace std;
using std::bitset;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x ) {
		if(x==0){
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		register int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
int temp[62],n,m;
struct T{
	int v[62];
	inline void rev(int x){
		memcpy(temp,v+m-x+1,x<<2);
		memmove(v+x+1,v+1,(m-x)<<2);
		memcpy(v+1,temp,x<<2);
	}
	inline void add(int x){
		F(i,1,m)v[i]+=x;
	}
}t[1000002],res;
inline void merge(T &rt,const T &x,const T &y){
	F(i,1,m)rt.v[i]=max(x.v[i],y.v[i]);
}
int r[1000002],a[1000002];
inline void putrev(int pos,int x){
	t[pos].rev(x);
	r[pos]=(r[pos]+x)%m;
}
inline void putadd(int pos,int x){
	t[pos].add(x);
	a[pos]+=x;
}
#define mid ((l+r)>>1)
inline void pushdown(int pos){
	if(r[pos]){
		putrev(pos<<1,r[pos]);
		putrev(pos<<1|1,r[pos]);
		r[pos]=0;
	}
	if(a[pos]){
		putadd(pos<<1,a[pos]);
		putadd(pos<<1|1,a[pos]);
		a[pos]=0;
	}
}
inline void pushup(int pos){
	merge(t[pos],t[pos<<1],t[pos<<1|1]);
}
int x[200002],y[200002];
inline void build(int pos,int l,int r){
	if(l==r){
		t[pos].v[x[l]]=y[l];
		return;
	}
	build(pos<<1,l,mid);build(pos<<1|1,mid+1,r);
	pushup(pos);
}
inline void R(int pos,int l,int r,int ql,int qr,int v){
	if(ql<=l&&qr>=r){
		putrev(pos,v);
		return;
	}
	pushdown(pos);
	if(ql<=mid)R(pos<<1,l,mid,ql,qr,v);
	if(qr>mid)R(pos<<1|1,mid+1,r,ql,qr,v);
	pushup(pos);
}
inline void A(int pos,int l,int r,int ql,int qr,int v){
	if(ql<=l&&qr>=r){
		putadd(pos,v);
		return;
	}
	pushdown(pos);
	if(ql<=mid)A(pos<<1,l,mid,ql,qr,v);
	if(qr>mid)A(pos<<1|1,mid+1,r,ql,qr,v);
	pushup(pos);
}
inline void query(int pos,int l,int r,int ql,int qr){
	if(ql<=l&&qr>=r){
		merge(res,res,t[pos]);
		return;
	}
	pushdown(pos);
	if(ql<=mid)query(pos<<1,l,mid,ql,qr);
	if(qr>mid)query(pos<<1|1,mid+1,r,ql,qr);
}
ll dp[62];
inline void query(int l,int r){//cerr<<t[1].v[1]<<endl;
	memset(res.v,0,sizeof(res.v));
	query(1,1,n,l,r);
	memset(dp,0,sizeof(dp));
	F(i,1,m)F(j,1,i)dp[i]=max(dp[i],dp[i-j]+res.v[j]);
	ll x=0,y=0;
	F(i,1,m){
		x+=dp[i];
		y^=dp[i];
	}
	write(x,' ');write(y,'\n');
}
int main(){
	cin>>n>>m;
	F(i,1,n)read(x[i]);
	F(i,1,n)read(y[i]);
	build(1,1,n);
	F(dsaf,1,read()){
		int op=read(),l=read(),r=read();
		if(op==1){
			R(1,1,n,l,r,read());
		}else if(op==2){
			A(1,1,n,l,r,read());
		}else query(l,r);
	}
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 9900kb

input:

4 10
1 6 10 2
100 2333 666 300
7
3 1 4
3 1 3
1 2 4 1
3 1 4
2 2 3 -1000
2 2 3 -600
3 2 4

output:

15165 2865
14165 2169
36630 798
4899 1273

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 164ms
memory: 136408kb

input:

200000 60
21 16 58 5 26 44 30 40 31 27 50 21 59 50 37 39 26 9 15 14 9 59 40 29 32 5 2 25 57 18 4 9 25 1 13 42 36 34 21 6 53 2 18 51 51 55 29 17 3 36 22 11 26 1 40 58 57 33 22 53 42 26 1 6 18 6 47 54 31 59 51 23 60 1 13 43 55 34 59 49 9 12 51 34 4 22 31 1 47 45 45 28 10 38 34 19 35 12 4 5 11 47 28 2 ...

output:

304478979 5965183
302725180 6346266
263891804 12270170
206665590 7376160
224407908 12588660
302401755 6812441
298016030 8641780
187482000 7499280
276575975 13386421
302685395 8377169
304347825 5950953
296928490 9925716
273952510 11264178
185846328 1238664
276368626 13405014
200927082 49156
84263735 ...

result:

wrong answer 17th lines differ - expected: '84257215 7195871', found: '84263735 7195415'