QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#719382 | #9535. Arrow a Row | find | AC ✓ | 27ms | 5376kb | C++23 | 1.6kb | 2024-11-07 00:30:52 | 2024-11-07 00:30:52 |
Judging History
answer
#include <bits/stdc++.h>
namespace stdv = std::views;
namespace stdr = std::ranges;
using i64 = long long;
void solve() {
std::string s;
std::cin >> s;
const int n = s.size();
if (s[0] != '>' || !s.contains('-') || s.substr(n - 3, 3) != ">>>") {
std::puts("No");
return;
}
std::vector<std::pair<int, int>> ans;
bool f = true;
for (int i = 0; i < n; i++) {
int j = i;
while (j + 1 < n && s[j + 1] != '-') {
j++;
}
int l = j;
if (j == n - 1) {
break;
}
while (j + 1 < n && s[j + 1] == '-') {
j++;
}
int k = j + 1;
while (j + 1 < n && s[j + 1] != '-') {
j++;
}
if (f) {
while (s[i] == '>') {
ans.emplace_back(i + 1, std::max(j - i + 1, k + 3 - i));
i++;
j -= 3;
}
while (j >= k) {
ans.emplace_back(l + 1, std::max(j - l + 1, k + 3 - l));
j -= 3;
}
} else {
while (j >= k) {
ans.emplace_back(l + 1, std::max(j - l + 1, k + 3 - l));
j -= 3;
}
}
i = k - 1;
f = false;
}
assert(ans.size() <= n);
printf("Yes %u\n", ans.size());
for (auto [a, b] : ans) {
printf("%d %d\n", a, b);
}
}
auto main() -> int {
int t;
scanf("%d", &t);
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3720kb
input:
4 >>->>> >>>-> >>>>> >->>>>>>
output:
Yes 2 1 6 2 5 No No Yes 2 1 8 1 5
result:
ok ok (4 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
126 >->-->>>> >--->->>>> >--->-->>> >>-->->>> >>-->>>>> >>->->>>> >>->>->>>> >-->->->>> >->->>>>>> >->>> >->->>>>> >>>->->>> >>->>>>>>> >>>>>->>> >->>>->>> >>--->->>> >>->>>> >->>>>->>> >>>>-->>> >---->>> >>>---->>> >>>>->>>> >->>-->>> >-->-->>>> >>---->>> >>--->>> >->>>-->>> >>-->>>> >>---->>>> >>-...
output:
Yes 3 1 5 3 7 3 6 Yes 3 1 7 5 6 5 5 Yes 2 1 7 5 6 Yes 3 1 7 2 6 5 5 Yes 2 1 9 2 6 Yes 4 1 6 2 5 4 6 4 5 Yes 4 1 6 2 5 5 6 5 5 Yes 3 1 6 4 5 6 5 Yes 3 1 5 3 8 3 5 Yes 1 1 5 Yes 3 1 5 3 7 3 5 Yes 4 1 7 2 6 3 5 5 5 Yes 3 1 10 2 6 2 5 Yes 5 1 9 2 8 3 7 4 6 5 5 Yes 2 1 5 5 5 Yes 3 1 8 2 7 6 5 Yes 2 1 7 2...
result:
ok ok (126 test cases)
Test #3:
score: 0
Accepted
time: 4ms
memory: 4020kb
input:
4032 >>--->>>>>>>> >->>->->-->->>> >>--->>--->>> >>->->->>>>>>>> >->---->->>> >->>->>---->>>> >>>>>>>>->>>> >->>>--->>>->>> >->>->>-->>>>>> >->>-->---->>> >-->--->>>->>> >->---->>-->>>> >>------>>> >>>-->>--->>>>> >->->->>-->>>> >->->-->>->->>> >>->>>>-->->>>> >>>-->>->--->>> >->->>>>>->>>> >>-->->>...
output:
Yes 3 1 13 2 9 2 7 Yes 5 1 5 4 5 6 5 8 6 11 5 Yes 3 1 8 2 7 7 7 Yes 6 1 6 2 5 4 5 6 10 6 7 6 5 Yes 3 1 5 3 8 8 5 Yes 4 1 5 4 5 7 9 7 8 Yes 8 1 13 2 11 3 10 4 9 5 8 6 7 7 6 8 5 Yes 3 1 5 5 7 11 5 Yes 4 1 5 4 5 7 9 7 6 Yes 3 1 5 4 6 7 8 Yes 3 1 6 4 7 10 5 Yes 4 1 5 3 8 9 7 9 6 Yes 2 1 11 2 10 Yes 5 1 ...
result:
ok ok (4032 test cases)
Test #4:
score: 0
Accepted
time: 8ms
memory: 4052kb
input:
10000 >>>>->->>->>->>>> >->-->>->>->>>>>> >->->>-->--->>>>> >---->-->->>>>>>> >->-->>--->>->>>> >->>->>>>>>-->>> >>--->->-->>->>> >-->---->>>->>> >->----->->->>>>> >>--->---->-->>>> >>-->->->--->>> >----->>-->>->>>> >-->->->>>>>->>>> >>->>---->-->>> >>->>-->>>-->>> >------>->>>->>>> >->->-->->>>->>>...
output:
Yes 8 1 8 2 7 3 6 4 5 6 5 9 5 12 6 12 5 Yes 5 1 5 3 6 7 5 10 8 10 5 Yes 5 1 5 3 5 6 6 9 9 9 7 Yes 5 1 8 6 6 9 9 9 6 9 5 Yes 5 1 5 3 6 7 7 12 6 12 5 Yes 4 1 5 4 8 4 5 11 6 Yes 5 1 8 2 7 6 5 8 6 12 5 Yes 3 1 6 4 8 11 5 Yes 5 1 5 3 9 9 5 11 7 11 5 Yes 5 1 8 2 7 6 8 11 7 11 6 Yes 5 1 7 2 6 5 5 7 5 9 7 Y...
result:
ok ok (10000 test cases)
Test #5:
score: 0
Accepted
time: 13ms
memory: 3772kb
input:
10000 >>>-->>>>-->---->->->-->>> >>-->>>>->-->>->>> >->-->--->--->->-->>--->>->->>-->->->>>>>>->>>>----->->--->>----->>-->>>----->->->>>--->>->>-->->->->---->>->>>-->>->->>>->->>>>->>->->>-->>>->>->>-->>>>-->>-->>>->>->->>>--->>>-->>>--->>->->>>>>->->---->>>>->>> ->->>>>--->>>>>>->>>->>>>->->-->-->>...
output:
Yes 8 1 9 2 7 3 6 9 6 12 8 17 5 19 5 21 6 Yes 5 1 8 2 6 8 5 10 6 14 5 Yes 61 1 5 3 6 6 7 10 7 14 5 16 6 20 7 25 5 27 5 30 6 33 5 35 8 35 5 42 6 42 5 47 9 53 5 55 7 60 9 67 6 72 9 78 5 80 5 84 7 89 5 92 6 95 5 97 5 99 5 101 8 107 5 111 6 115 5 117 5 121 5 123 6 123 5 128 5 131 5 133 5 136 6 141 5 144...
result:
ok ok (10000 test cases)
Test #6:
score: 0
Accepted
time: 27ms
memory: 3792kb
input:
9999 ->->--->>>>->->--->>-- ->>>--->>>-->>--->>--- -->>>>>>>- >>>->>>>>>>-- >>-->-->->----->->>>>->>->---->-> >-->->>>--->->->>->->- >->--->--->>>>->>>----->------>>-->->>> >>->>>->>>---->>>->>>>>>>>>->--->>->>>>>-->>>->->->>-->->--->->-->->>->->->>-->-->>>>>>>>--->>--->->>>-->->----->>-->->>--->-->...
output:
No No No No No No Yes 9 1 5 3 7 7 8 7 7 14 5 18 9 24 10 32 6 35 5 Yes 38 1 6 2 5 6 5 10 8 17 11 17 8 17 5 27 5 29 7 34 7 34 5 40 6 45 5 47 5 49 5 52 6 55 5 57 7 61 5 63 6 66 5 69 5 71 5 73 5 76 6 79 11 79 8 79 6 89 7 94 7 98 5 102 6 105 5 107 9 114 6 117 5 120 7 124 6 Yes 28 1 5 4 7 4 6 10 5 12 9 18...
result:
ok ok (9999 test cases)
Test #7:
score: 0
Accepted
time: 5ms
memory: 4084kb
input:
5 >-->>>>>--->->->>->>>>>->->-->-->->>>-->->--->>>------>->>-->>>------->>---->-->>>>>>-->>--->>-->->->>>>->-->------>>->>>>->>>-->---->--->>-->-->->--->->->->->>->-->->--->>>>->>->--->->>-->>>>>>->>>>->>--->->>-->>->->---->>>->->>->>->--->->->-->->>->->-->->------>>>->>>>>->>-->>->>>->>>>>----->---...
output:
No No Yes 27414 1 7 2 6 3 5 7 5 10 5 12 9 12 8 20 5 24 5 28 5 30 6 34 5 37 6 37 5 42 6 42 5 47 7 51 6 54 11 54 9 64 5 68 6 73 5 77 7 83 7 88 6 91 5 94 8 100 8 106 5 108 13 119 10 119 7 128 5 130 7 134 7 138 8 144 6 147 8 152 7 157 6 160 6 163 9 170 5 174 8 179 5 181 7 185 5 187 7 187 5 193 5 195 6 1...
result:
ok ok (5 test cases)
Test #8:
score: 0
Accepted
time: 19ms
memory: 5376kb
input:
5 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
No Yes 99995 1 100000 2 99998 3 99997 4 99996 5 99995 6 99994 7 99993 8 99992 9 99991 10 99990 11 99989 12 99988 13 99987 14 99986 15 99985 16 99984 17 99983 18 99982 19 99981 20 99980 21 99979 22 99978 23 99977 24 99976 25 99975 26 99974 27 99973 28 99972 29 99971 30 99970 31 99969 32 99968 33 9996...
result:
ok ok (5 test cases)
Test #9:
score: 0
Accepted
time: 9ms
memory: 4240kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 14212 1 16246 2 16242 3 16238 4 16234 5 16230 6 16226 7 16222 8 16218 9 16214 10 16210 11 16206 12 16202 13 16198 14 16194 15 16190 16 16186 17 16182 18 16178 19 16174 20 16170 21 16166 22 16162 23 16158 24 16154 25 16150 26 16146 27 16142 28 16138 29 16134 30 16130 31 16126 32 16122 33 16118 34...
result:
ok ok (20 test cases)
Test #10:
score: 0
Accepted
time: 10ms
memory: 3988kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 7574 1 25000 2 24996 3 24992 4 24988 5 24984 6 24980 7 24976 8 24972 9 24968 10 24964 11 24960 12 24956 13 24952 14 24948 15 24944 16 24940 17 24936 18 24932 19 24928 20 24924 21 24920 22 24916 23 24912 24 24908 25 24904 26 24900 27 24896 28 24892 29 24888 30 24884 31 24880 32 24876 33 24872 34 ...
result:
ok ok (20 test cases)
Extra Test:
score: 0
Extra Test Passed