QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421168#6822. Bracket QuerykjhhjkiWA 17ms5160kbC++201.4kb2024-05-25 14:36:102024-05-25 14:36:10

Judging History

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

  • [2024-05-25 14:36:10]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:5160kb
  • [2024-05-25 14:36:10]
  • 提交

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;
}

详细

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