QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#887873#10012. Make It RegularBreakPlusWA 122ms120448kbC++141.6kb2025-02-07 20:21:402025-02-07 20:21:41

Judging History

This is the latest submission verdict.

  • [2025-02-07 20:21:41]
  • Judged
  • Verdict: WA
  • Time: 122ms
  • Memory: 120448kb
  • [2025-02-07 20:21:40]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
#define popcnt __builtin_popcountll
const ll mod = 998244353;
inline ll read(){
	ll x=0, f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
	return x*f;
}
inline int lg2(int x){ return 31^__builtin_clz(x); }
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline void addmod(int &x){ if(x >= mod) x -= mod; }
inline void addmod(ll &x){ if(x >= mod) x -= mod; }
inline ll qpow(ll a,ll b){
	ll ans=1, base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod; b>>=1;
	}
	return ans;
}
inline ll INV(ll x){ return qpow(x, mod-2); };
int n; char s[6005];
int dp[6005][3005][2];
inline int ok(char ch){ return ch=='('?1:-1;}
void procedure(){
	n=read();
	scanf("%s", s);
	dp[0][0][0] = 1;
	for(int i=0;i<2*n;i++)
		for(int j=0;j<=n;j++)
			for(auto o: {0,1}){
				if(!dp[i][j][o]) continue;
				if(j+ok(s[i])>=0) addmod(dp[i+1][j+ok(s[i])][o] += dp[i][j][o]); // do not choose
				if(j) addmod(dp[i+1][j-1][1] += dp[i][j][o]);
				if(!o) addmod(dp[i+1][j+1][0] += dp[i][j][o]);
			}
	printf("%d\n", (dp[2*n][0][0]+dp[2*n][0][1])%mod);
}
int main(){
	#ifdef LOCAL
		assert(freopen("input.txt","r",stdin));
		assert(freopen("output.txt","w",stdout));
	#endif
	ll T=1;
	// math_init();
	// NTT::init();
	while(T--) procedure();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3840kb

input:

3
())(()

output:

36

result:

ok 1 number(s): "36"

Test #2:

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

input:

6
()))(())()((

output:

1536

result:

ok 1 number(s): "1536"

Test #3:

score: 0
Accepted
time: 112ms
memory: 120448kb

input:

3000
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

572364310

result:

ok 1 number(s): "572364310"

Test #4:

score: 0
Accepted
time: 109ms
memory: 120192kb

input:

3000
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

625414787

result:

ok 1 number(s): "625414787"

Test #5:

score: 0
Accepted
time: 101ms
memory: 120448kb

input:

3000
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

518609146

result:

ok 1 number(s): "518609146"

Test #6:

score: 0
Accepted
time: 112ms
memory: 120320kb

input:

3000
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

982003712

result:

ok 1 number(s): "982003712"

Test #7:

score: 0
Accepted
time: 110ms
memory: 120448kb

input:

3000
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))))))))))))))...

output:

699842210

result:

ok 1 number(s): "699842210"

Test #8:

score: 0
Accepted
time: 117ms
memory: 120448kb

input:

3000
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

92487102

result:

ok 1 number(s): "92487102"

Test #9:

score: 0
Accepted
time: 117ms
memory: 120448kb

input:

3000
)))))))))))())))())))))))))))))))))()))))))))))()))))))))))))()))))))())))))())))))()))))))())))()))))))))))()))))())))))))()))))))()))))))))()))()))))))()))))))()))())())))))))))))())))))()))))))())))))()))()))))))))))()))))))))))))())))))())))))))))())))))))())))))))()))))())))))))))())))))))...

output:

450713213

result:

ok 1 number(s): "450713213"

Test #10:

score: 0
Accepted
time: 112ms
memory: 120448kb

input:

3000
)))))()))))))())))()))))))))())))())))))))())))))))()))))))())))())))))))))()))))))()))())))))))))()))))))))()))))))())))()))))))()))())))))))))())))))())))))))()))))))))())()))())))))))))())))))))))()))())))))())))))()))))))))())))))))))))))))())))))))))))())))))))))))())))))))()))))))()))))))...

output:

584092325

result:

ok 1 number(s): "584092325"

Test #11:

score: 0
Accepted
time: 113ms
memory: 120448kb

input:

3000
)))())))())))())))))()))()))))))())))()))))())))()))()))))))()))))))))())))())))))()))()))()))))))))())))))())))))())()))))))())))))())))())))())))))))())))))))))()))))())))))()))()))))))))))())))))))))()))))))()))))()))))())))))))()))))))()))))())())))))()))())())))()))))))()))))())))()))))))(...

output:

497490320

result:

ok 1 number(s): "497490320"

Test #12:

score: 0
Accepted
time: 110ms
memory: 120448kb

input:

3000
))))()))))())()))))()))())()))))()))())))())))))()))))())))()))())()))))))())))))()))))))))())))())))))()))))))()))()))))()))()))))())))))))()))))))))())()))()))))()))()()))))())))()))()))))())))())))))()))))()))())))()))))())())))()))))()))()))))()))()))))))())()())))()))))))())))())))()))()))...

output:

893741400

result:

ok 1 number(s): "893741400"

Test #13:

score: 0
Accepted
time: 115ms
memory: 120448kb

input:

3000
))()))()())))()))())())()))()))()))())()))())(())())))())())))()())()()))()())())()()))()())())()))(())()()()())()()))()(())()()(()))())))))())())())))()((()())))())())())))())())()))())()()()))()())())()()()()))))(()(()))())())()))())()))())()())))())()(()()))(()())))))()))()())()(()()(()))))(...

output:

405246052

result:

ok 1 number(s): "405246052"

Test #14:

score: 0
Accepted
time: 122ms
memory: 120448kb

input:

3000
)))())())())())())()()))())())()))())()))()))))()()))()(())())))()((())()()))()(()))(()))))())))()())))()()())())))))())()()))(())))()))()))())())())))())()())())()))((())()))())())()())()))())))((()))))()())())()))())()(())))(()()())()))())())()))()())()))(())))()())()())))()))())(()))()))()))...

output:

604182464

result:

ok 1 number(s): "604182464"

Test #15:

score: 0
Accepted
time: 120ms
memory: 120448kb

input:

3000
))())())(()(()()())))()()(()))(()())())((())))())()()(())()))(())(()(((()(((((()()()()()()(((()((())())))())(())()(())()()(()())(()))()()()(()())(())()()(()()(()()()()(()())()())))(()(()()(()(()(()())())()()())()((())()(((())))())()(()(()((())()((())())())()()())())(())()()(()))(()()(((()(()))(...

output:

367367502

result:

ok 1 number(s): "367367502"

Test #16:

score: 0
Accepted
time: 122ms
memory: 120448kb

input:

3000
)()(()(()()(()(()()))(((((((()(()())((()(())((()(((()))())(()()()(()()()())()((())((()())(())(()()((())()())))()(((((()((()(()()()(())()()()())())))())(())()()()()((()(()(((()()((()(())(()))()))()())(())))()()()()())()))(())(()))((()()(())((()(()(()()))())()(((()())(())))()((()((((())(()()())()...

output:

602303293

result:

ok 1 number(s): "602303293"

Test #17:

score: -100
Wrong Answer
time: 115ms
memory: 120448kb

input:

3000
(((((((((((((((((((((((((((((((((((((((((((((((((((((()(((((((((((((()((()((((((((((((((((((((((((((((((((((((((((((((((())((((((((((((()()(((((((((((()(((()((((((((((((((((((()(((((((()(((((((((()((((((((((((((((((((((((((((((()((((((((((((((()(()()()((((((()(()(((((((((((()(((((((((((((((((((...

output:

384656803

result:

wrong answer 1st numbers differ - expected: '384656802', found: '384656803'