QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190574 | #3673. Generalized German Quotation | MaGnsi0# | WA | 0ms | 3740kb | C++17 | 1014b | 2023-09-29 05:11:02 | 2023-09-29 05:11:03 |
Judging History
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 `<'