QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#421168 | #6822. Bracket Query | kjhhjki | WA | 17ms | 5160kb | C++20 | 1.4kb | 2024-05-25 14:36:10 | 2024-05-25 14:36:10 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i, a, b) for(i32 i = (a), endi = (b); i <= endi; ++i)
#define foR(i, a, b) for(i32 i = (a), endi = (b); i >= endi; --i)
using namespace std;
template<typename T, typename U>
void chkmin(T &a, U b) { if(a > b) a = b; }
using i32 = int;
using i64 = long long;
using f64 = long double;
using pii = pair<i32, i32>;
void init() { }
void solve()
{
i32 n, m;
cin >> n >> m;
vector<vector<pii>> pos(n+1);
For(i, 1, m)
{
i32 l, r, c;
cin >> l >> r >> c;
pos[r].emplace_back(l-1, c);
}
vector dp(n+1, vector(n+1, false));
dp[0][0] = true;
For(x, 1, n) For(y, 0, n / 2)
{
if(y) dp[x][y] = dp[x][y] | dp[x-1][y-1];
dp[x][y] = dp[x][y] | dp[x-1][y+1];
for(auto [l, del]: pos[x])
{
if(y - del < 0 || y - del > n) dp[x][y] = false;
dp[x][y] = dp[x][y] & dp[l][y - del];
}
}
if(!dp[n][0])
{
cout << "?\n";
return;
}
cout << "! ";
i32 x = n, y = 0;
string res;
while(x)
{
--x;
if(y && dp[x][y-1]) res.push_back('('), --y;
else res.push_back(')'), ++y;
}
reverse(res.begin(), res.end());
cout << res << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
init();
i32 T = 1;
// cin >> T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
4 1 1 2 0
output:
! ()()
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
4 1 1 2 2
output:
! (())
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
2 2 1 1 1 2 2 -1
output:
! ()
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
2 1 1 1 2
output:
?
result:
ok ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3808kb
input:
4 0
output:
! ()()
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
8 2 1 5 1 3 7 1
output:
! ()()()()
result:
ok ok
Test #7:
score: 0
Accepted
time: 16ms
memory: 5160kb
input:
3000 0
output:
! ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()...
result:
ok ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
2 1 1 2 2
output:
?
result:
ok ok
Test #9:
score: 0
Accepted
time: 16ms
memory: 5020kb
input:
3000 1 1 3000 0
output:
! ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()...
result:
ok ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
8 2 1 6 2 3 7 1
output:
! ()()(())
result:
ok ok
Test #11:
score: -100
Wrong Answer
time: 17ms
memory: 4968kb
input:
3000 3 1111 1113 3 1112 1114 -1 1113 1115 3
output:
! ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()...
result:
wrong answer requirement not satisified