QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#807185 | #9535. Arrow a Row | Sword1E1 | AC ✓ | 21ms | 7016kb | C++23 | 2.0kb | 2024-12-09 19:45:28 | 2024-12-09 19:45:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
std::cout << std::endl;
}
template<class T, class... Ts>
void err(T arg, Ts &... args) {
std::cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
void GENSHEN_START() {
string check = ">->>>";
string s;cin >> s;
vector <pair<int,int>> ans;
int len = s.size();
int l = -1,r = -1;
for (int i = len - 5;i >= 0;i--) {
if (s[i] == '>') {
int j = i + 1;
if (s[j] == '-') {
for (;j < len;j++) {
if (s[j] == '>') break;
}
if (j + 2 < len) {
if (s[j] == '>' && s[j + 1] == '>' && s[j + 2] == '>') {
l = i,r = j + 2;
ans.push_back({l,r - l + 1});
break;
}
}
}
}
}
if (l == -1) {
cout << "No" << '\n';
return ;
}
for (int i = l - 1;i >= 0;i--) {
if (s[i] == '>') {
ans.push_back({i,r - i + 1});
}
else {
int ok = 0;
int j = i;
for (;j >= 0;j--) {
if (s[j] == '>') {
ok = 1;
ans.push_back({j,r - j + 1});
break;
}
}
if (!ok) {
cout << "No" << '\n';
return ;
}
i = j;
}
}
for (int i = r + 1;i < len;i++) {
if (s[i] == '>') {
ans.push_back({l,i - l + 1});
}
else {
int j = i;
for (;j < len;j++) {
if (s[j] == '>') {
break;
}
}
if (j + 2 < len) {
if (s[j] == '>' && s[j + 1] == '>' && s[j + 2] == '>') {
ans.push_back({l,j + 2 - l + 1});
i = j + 2;
}
else {
cout << "No" << '\n';
return ;
}
}
else {
cout << "No" << '\n';
return ;
}
}
}
reverse(ans.begin(),ans.end());
cout << "Yes" << ' ' << ans.size() << '\n';
for (auto [u,v] : ans) cout << u + 1 << ' ' << v << '\n';
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) GENSHEN_START();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
input:
4 >>->>> >>>-> >>>>> >->>>>>>
output:
Yes 2 1 6 2 5 No No Yes 4 1 8 1 7 1 6 1 5
result:
ok ok (4 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
126 >->-->>>> >--->->>>> >--->-->>> >>-->->>> >>-->>>>> >>->->>>> >>->>->>>> >-->->->>> >->->>>>>> >->>> >->->>>>> >>>->->>> >>->>>>>>> >>>>>->>> >->>>->>> >>--->->>> >>->>>> >->>>>->>> >>>>-->>> >---->>> >>>---->>> >>>>->>>> >->>-->>> >-->-->>>> >>---->>> >>--->>> >->>>-->>> >>-->>>> >>---->>>> >>-...
output:
Yes 3 3 7 1 8 3 6 Yes 3 5 6 1 9 5 5 Yes 2 1 10 5 6 Yes 3 1 9 2 8 5 5 Yes 4 2 8 2 7 1 7 2 6 Yes 4 4 6 1 8 2 7 4 5 Yes 5 5 6 1 9 2 8 4 6 5 5 Yes 3 1 10 4 7 6 5 Yes 5 3 8 3 7 3 6 1 7 3 5 Yes 1 1 5 Yes 4 3 7 3 6 1 7 3 5 Yes 4 1 9 2 8 3 7 5 5 Yes 6 2 9 2 8 2 7 2 6 1 6 2 5 Yes 5 1 9 2 8 3 7 4 6 5 5 Yes 4 ...
result:
ok ok (126 test cases)
Test #3:
score: 0
Accepted
time: 3ms
memory: 3876kb
input:
4032 >>--->>>>>>>> >->>->->-->->>> >>--->>--->>> >>->->->>>>>>>> >->---->->>> >->>->>---->>>> >>>>>>>>->>>> >->>>--->>>->>> >->>->>-->>>>>> >->>-->---->>> >-->--->>>->>> >->---->>-->>>> >>------>>> >>>-->>--->>>>> >->->->>-->>>> >->->-->>->->>> >>->>>>-->->>>> >>>-->>->--->>> >->->>>>>->>>> >>-->->>...
output:
Yes 7 2 12 2 11 2 10 2 9 2 8 1 8 2 7 Yes 6 1 15 3 13 4 12 6 10 8 8 11 5 Yes 4 1 13 2 12 6 8 7 7 Yes 9 6 10 6 9 6 8 6 7 6 6 1 10 2 9 4 7 6 5 Yes 3 1 12 3 10 8 5 Yes 6 7 9 1 14 3 12 4 11 6 9 7 8 Yes 9 8 6 1 12 2 11 3 10 4 9 5 8 6 7 7 6 8 5 Yes 7 1 15 3 13 4 12 5 11 9 7 10 6 11 5 Yes 8 7 9 7 8 7 7 1 12...
result:
ok ok (4032 test cases)
Test #4:
score: 0
Accepted
time: 8ms
memory: 3592kb
input:
10000 >>>>->->>->>->>>> >->-->>->>->>>>>> >->->>-->--->>>>> >---->-->->>>>>>> >->-->>--->>->>>> >->>->>>>>>-->>> >>--->->-->>->>> >-->---->>>->>> >->----->->->>>>> >>--->---->-->>>> >>-->->->--->>> >----->>-->>->>>> >-->->->>>>>->>>> >>->>---->-->>> >>->>-->>>-->>> >------>->>>->>>> >->->-->->>>->>>...
output:
Yes 10 12 6 1 16 2 15 3 14 4 13 6 11 8 9 9 8 11 6 12 5 Yes 9 10 8 10 7 10 6 1 14 3 12 6 9 7 8 9 6 10 5 Yes 7 9 9 9 8 1 15 3 13 5 11 6 10 9 7 Yes 7 9 9 9 8 9 7 9 6 1 13 6 8 9 5 Yes 7 12 6 1 16 3 14 6 11 7 10 11 6 12 5 Yes 9 1 16 3 14 4 13 6 11 7 10 8 9 9 8 10 7 11 6 Yes 6 1 16 2 15 6 11 8 9 11 6 12 5...
result:
ok ok (10000 test cases)
Test #5:
score: 0
Accepted
time: 14ms
memory: 3696kb
input:
10000 >>>-->>>>-->---->->->-->>> >>-->>>>->-->>->>> >->-->--->--->->-->>--->>->->>-->->->>>>>>->>>>----->->--->>----->>-->>>----->->->>>--->>->>-->->->->---->>->>>-->>->->>>->->>>>->>->->>-->>>->>->>-->>>>-->>-->>>->>->->>>--->>>-->>>--->>->->>>>>->->---->>>>->>> ->->>>>--->>>>>>->>>->>>>->->-->-->>...
output:
Yes 11 1 26 2 25 3 24 6 21 7 20 8 19 9 18 12 15 17 10 19 8 21 6 Yes 9 1 18 2 17 5 14 6 13 7 12 8 11 10 9 13 6 14 5 Yes 110 1 211 3 209 6 206 10 202 14 198 16 196 19 193 20 192 24 188 25 187 27 185 29 183 30 182 33 179 35 177 37 175 38 174 39 173 40 172 41 171 42 170 44 168 45 167 46 166 47 165 53 15...
result:
ok ok (10000 test cases)
Test #6:
score: 0
Accepted
time: 14ms
memory: 3656kb
input:
9999 ->->--->>>>->->--->>-- ->>>--->>>-->>--->>--- -->>>>>>>- >>>->>>>>>>-- >>-->-->->----->->>>>->>->---->-> >-->->>>--->->->>->->- >->--->--->>>>->>>----->------>>-->->>> >>->>>->>>---->>>->>>>>>>>>->--->>->>>>>-->>>->->->>-->->--->->-->->>->->->>-->-->>>>>>>>--->>--->->>>-->->----->>-->->>--->-->...
output:
No No No No No No Yes 14 1 39 3 37 7 33 11 29 12 28 13 27 14 26 16 24 17 23 18 22 24 16 31 9 32 8 35 5 Yes 69 1 129 2 128 4 126 5 125 6 124 8 122 9 121 10 120 15 115 16 114 17 113 19 111 20 110 21 109 22 108 23 107 24 106 25 105 26 104 27 103 29 101 33 97 34 96 36 94 37 93 38 92 39 91 40 90 43 87 44...
result:
ok ok (9999 test cases)
Test #7:
score: 0
Accepted
time: 8ms
memory: 5268kb
input:
5 >-->>>>>--->->->>->>>>>->->-->-->->>>-->->--->>>------>->>-->>>------->>---->-->>>>>>-->>--->>-->->->>>>->-->------>>->>>>->>>-->---->--->>-->-->->--->->->->->>->-->->--->>>>->>->--->->>-->>>>>>->>>>->>--->->>-->>->->---->>>->->>->>->--->->->-->->>->->-->->------>>>->>>>>->>-->>->>>->>>>>----->---...
output:
No No Yes 48171 1 95948 2 95947 3 95946 5 95944 6 95943 7 95942 9 95940 10 95939 12 95937 17 95932 18 95931 19 95930 20 95929 22 95927 23 95926 24 95925 26 95923 27 95922 28 95921 30 95919 33 95916 34 95915 36 95913 37 95912 39 95910 40 95909 41 95908 42 95907 44 95905 45 95904 46 95903 47 95902 51 ...
result:
ok ok (5 test cases)
Test #8:
score: 0
Accepted
time: 11ms
memory: 7016kb
input:
5 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
No Yes 99996 99995 6 1 99999 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 ...
result:
ok ok (5 test cases)
Test #9:
score: 0
Accepted
time: 14ms
memory: 4328kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 24994 19003 5998 19003 5997 19003 5996 19003 5995 19003 5994 19003 5993 19003 5992 19003 5991 19003 5990 19003 5989 19003 5988 19003 5987 19003 5986 19003 5985 19003 5984 19003 5983 19003 5982 19003 5981 19003 5980 19003 5979 19003 5978 19003 5977 19003 5976 19003 5975 19003 5974 19003 5973 1900...
result:
ok ok (20 test cases)
Test #10:
score: 0
Accepted
time: 21ms
memory: 4092kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 24996 2278 22723 2278 22722 2278 22721 2278 22720 2278 22719 2278 22718 2278 22717 2278 22716 2278 22715 2278 22714 2278 22713 2278 22712 2278 22711 2278 22710 2278 22709 2278 22708 2278 22707 2278 22706 2278 22705 2278 22704 2278 22703 2278 22702 2278 22701 2278 22700 2278 22699 2278 22698 2278...
result:
ok ok (20 test cases)
Extra Test:
score: 0
Extra Test Passed