QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#286562#7973. 括号Crysfly5 52ms5864kbC++172.7kb2023-12-18 01:10:202023-12-18 01:10:20

Judging History

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

  • [2023-12-18 01:10:20]
  • 评测
  • 测评结果:5
  • 用时:52ms
  • 内存:5864kb
  • [2023-12-18 01:10:20]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}
 
#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define inf 0x3f3f3f3f

int n,m,a[maxn];
char s[maxn];

void brute(){
	priority_queue<int,vector<int>,greater<int> >q;
	int res=0;
	For(i,1,n){
		if(s[i]==')')q.push(a[i]);
		else q.push(-a[i]),res+=a[i];
		if(i%2==1)res+=q.top(),q.pop();
	}
	cout<<res<<"\n";
}

signed main()
{
	n=read()*2,m=read();
	For(i,1,n)a[i]=read();
	cin>>(s+1);
	brute();
	For(i,1,m){
		int x=read(),y=read();
		a[x]=y;
		brute();
	}
	return 0;
}
/*

*/

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 15
Accepted
time: 1ms
memory: 3528kb

input:

100 100
655884441 790777510 663667368 332762945 67681448 458058488 445481314 200508190 812326927 374891900 320371513 765529851 490260632 588113266 286392696 888016940 214376080 894477437 944447014 386015667 956960774 692332579 606560669 561835357 887377361 130572961 550186106 193341110 4130416 66982...

output:

1883520337
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
1938040724
193...

result:

ok 101 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

100 100
833141622 854468469 367770104 350280219 461621010 985561079 287746098 833893180 365597420 618761946 416883128 838478689 419500348 996463737 903782689 176582886 101963967 728502271 222282338 808921916 744579730 171837013 508527221 141613052 233501822 501818380 143462266 206528940 451714614 68...

output:

140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
140782913
...

result:

ok 101 lines

Test #3:

score: -15
Wrong Answer
time: 1ms
memory: 3584kb

input:

100 100
897203289 398741091 737994838 918141180 881683740 708870393 569981059 825462339 575892019 654430241 400748227 892258264 55868417 318639212 157441109 208939722 240809609 552556736 89466637 625250145 859111121 925840769 588412874 550260548 581965340 250456136 598142176 155996841 785774919 7347...

output:

-868536548
-868536548
-696689509
-696689509
-696689509
-288682569
-288682569
-288682569
-51258665
353415299
353415299
353415299
170838411
72517148
-307173054
-307173054
-307173054
-324924656
-324924656
-324924656
-723886100
-723886100
-723886100
-729691364
-659366963
-891941082
-1176279295
-14505630...

result:

wrong answer 1st lines differ - expected: '16311332636', found: '-868536548'

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 47ms
memory: 3500kb

input:

1000 1000
851064227 277152131 421722407 126468670 510326499 619107836 287335428 653386549 173788833 304176934 21753544 293653999 493165671 887566717 813114839 976556173 459946448 939807420 605205411 920860669 545229689 895277168 777349694 126341157 564711820 892644312 314220085 125767094 816813109 9...

output:

-1501513352
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1510759336
-1494240136
-1494240136
...

result:

wrong answer 1st lines differ - expected: '2793453944', found: '-1501513352'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 5
Accepted

Test #14:

score: 5
Accepted
time: 52ms
memory: 3496kb

input:

1000 1000
49658 21707 94558 56676 18487 74906 55206 78654 54538 14591 105694 138 3148 106151 90191 67461 90337 86524 39272 78899 111590 3181 67245 47146 1958 34378 6544 74125 93643 44483 2159 16309 41619 24332 1519 85340 25811 55827 51528 89913 71355 103446 97370 44299 107887 105014 44419 62592 1965...

output:

13395019
13351991
13351991
13351991
13351991
13351991
13351991
13351991
13351991
13381782
13345375
13349826
13338684
13322461
13322461
13322461
13322461
13322461
13306716
13289968
13289968
13289968
13290694
13282032
13302932
13286589
13317058
13317058
13360189
13360189
13360189
13360189
13390898
133...

result:

ok 1001 lines

Test #15:

score: 0
Accepted
time: 52ms
memory: 5808kb

input:

1000 1000
48741 78915 65982 52179 49201 75885 71026 47007 75592 105723 58292 60053 94233 34736 3710 50633 88449 99895 6144 61740 40074 112109 81809 59449 27344 83326 27661 35015 77525 23183 80535 33235 2240 78293 2764 106350 97971 96527 35415 39791 85893 54169 7133 70924 78499 65993 50156 97046 1068...

output:

681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
681032
682276
682276
682276
682276
682276
679002
679002
679002
679002
679002
679002
679002
679002
679002
679002
679002
679002
679002
679002
679002...

result:

ok 1001 lines

Test #16:

score: 0
Accepted
time: 47ms
memory: 5864kb

input:

1000 1000
76312 85088 66287 101457 27652 113578 8522 27466 987 58477 35566 78626 108889 44590 16599 47446 67053 39487 52617 87121 78483 19460 4800 15209 108770 6107 94056 36407 4650 86935 13645 2732 4654 88828 32502 62313 15892 31506 81748 52589 103711 76765 98121 40569 110053 46753 8316 22781 54642...

output:

195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202
195202...

result:

ok 1001 lines

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%