QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190574#3673. Generalized German QuotationMaGnsi0#WA 0ms3740kbC++171014b2023-09-29 05:11:022023-09-29 05:11:03

Judging History

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

  • [2023-09-29 05:11:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3740kb
  • [2023-09-29 05:11:02]
  • 提交

answer

/**
 *    author:  MaGnsi0
 *    created: 29.09.2023 00:06:34
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int n = (int)s.size() / 2;
    set<int> L, R;
    for (int i = 0; i < n; ++i) {
        if (s[2 * i] == '<') {
            L.insert(i);
        } else {
            R.insert(i);
        }
    }
    if ((int)L.size() != (int)R.size()) {
        cout << "Keine Loesung";
        return 0;
    }
    string ans(n, '*');
    while (!L.empty() && !R.empty()) {
        int x = *L.begin();
        int y = *R.begin();
        if (x < y) {
            int z = *R.rbegin();
            ans[x] = '[';
            ans[z] = ']';
            L.erase(x);
            R.erase(z);
        } else {
            int z = *L.rbegin();
            ans[y] = '[';
            ans[z] = ']';
            L.erase(z);
            R.erase(y);
        }
    }
    cout << ans;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3740kb

input:

<<>><<<<>>>>

output:

[[[]]]

result:

wrong answer `]' closes quote of the same type `<'