QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#286563 | #7973. 括号 | Crysfly | 0 | 52ms | 5644kb | C++17 | 2.7kb | 2023-12-18 01:18:40 | 2023-12-18 01:18:41 |
Judging History
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;
ll res=0;
For(i,1,n){
if(s[i]==')')q.push(a[i]);
else q.push(-a[i]),res+=a[i];
if(i%2==0)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;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5632kb
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:
1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 1084918454 108...
result:
wrong answer 1st lines differ - expected: '1883520337', found: '1084918454'
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 48ms
memory: 5644kb
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:
1924990280 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1913963741 1932263496 1932263496 1932263496 1932263496 193...
result:
wrong answer 1st lines differ - expected: '2793453944', found: '1924990280'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 52ms
memory: 3552kb
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:
13382890 13339862 13339862 13339862 13339862 13339862 13339862 13339862 13339862 13369653 13333246 13337697 13326555 13310332 13310332 13310332 13310332 13310332 13294587 13277839 13277839 13277839 13278565 13269903 13290803 13274460 13304929 13304929 13348060 13348060 13348060 13348060 13378769 133...
result:
wrong answer 1st lines differ - expected: '13395019', found: '13382890'
Subtask #5:
score: 0
Skipped
Dependency #3:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%