QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711967 | #9535. Arrow a Row | bhscer | AC ✓ | 212ms | 6984kb | C++17 | 2.3kb | 2024-11-05 14:10:03 | 2024-11-05 14:10:07 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define fadd(a,b,c) for (int a=b;a<=c;a++)
#define fsub(a,b,c) for (int a=b;a>=c;a--)
#define F first
#define S second
#define CYes cout << "Yes\n"
#define CNo cout << "No\n"
#define CYES cout << "YES\n"
#define CNO cout << "NO\n"
#define println(a) cout << (a) << '\n'
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void fastIO(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
class bhscer {
public:
template<typename FIRST, typename ...PACK> static void debug(FIRST first, PACK... params) { std::cout<< first <<' '; debug(params...);}
template<typename T> static void debug(T end) { std::cout << end << std::endl; }
};
const int N = 5e5;
void solve() {
string s; cin >> s;
int n = s.size(); s = " " + s;
string ne = " " + string(n, '*');
auto fill = [&](PII rg) {
auto [l,r] = rg;
for (int i=l;i<=r;i++) {
if (i == l || i > r-3) ne[i] = '>';
else ne[i] = '-';
}
};
// base checks
if (s[1] == '-' || s[n] == '-' || s[n-1] == '-' || s[n-2] == '-') {
CNo;
return;
}
// we cover back first
int j = n;
while (j >= 1 && s[j] != '-') j --;
if (j == 0) {
CNo;
return;
}
vector<PII> p1;
for (int i=j;i<=n;i+=3) {
// >--------------->>>|>>>|>>>
// 1 i
p1.push_back({1,min(n, i+3)});
}
reverse(p1.begin(), p1.end());
for (auto rg: p1) {
fill(rg);
}
for (int i=1;i<j;i++) {
if (s[i+1] == '>') {
// >>>--->>>--??----->>>>>>>>
// i j
p1.push_back({i, j+3});
} else {
int k = i+1;
while (k+1 <= j && s[k+1] == '-') k++;
// >--------->>>?????
// i k
p1.push_back({i, k+3});
fill({i, k+3});
i = k;
}
}
cout << "Yes " << p1.size() << '\n';
for (auto [l,r]: p1) {
cout << l << ' ' << r-l+1 << '\n';
}
// cout << ne << '\n';
}
signed main() {
fastIO();
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
4 >>->>> >>>-> >>>>> >->>>>>>
output:
Yes 4 1 6 1 6 1 6 2 5 No No Yes 4 1 8 1 8 1 5 1 5
result:
ok ok (4 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
126 >->-->>>> >--->->>>> >--->-->>> >>-->->>> >>-->>>>> >>->->>>> >>->>->>>> >-->->->>> >->->>>>>> >->>> >->->>>>> >>>->->>> >>->>>>>>> >>>>>->>> >->>>->>> >>--->->>> >>->>>> >->>>>->>> >>>>-->>> >---->>> >>>---->>> >>>>->>>> >->>-->>> >-->-->>>> >>---->>> >>--->>> >->>>-->>> >>-->>>> >>---->>>> >>-...
output:
Yes 4 1 9 1 8 1 5 3 6 Yes 4 1 10 1 9 1 7 5 5 Yes 4 1 10 1 10 1 7 5 6 Yes 5 1 9 1 9 1 9 2 6 5 5 Yes 4 1 9 1 7 1 7 2 6 Yes 5 1 9 1 8 1 8 2 5 4 5 Yes 6 1 10 1 9 1 9 2 5 4 6 5 5 Yes 5 1 10 1 10 1 6 4 5 6 5 Yes 5 1 10 1 10 1 7 1 5 3 5 Yes 3 1 5 1 5 1 5 Yes 4 1 9 1 7 1 5 3 5 Yes 6 1 9 1 9 1 9 2 8 3 5 5 5 ...
result:
ok ok (126 test cases)
Test #3:
score: 0
Accepted
time: 4ms
memory: 3536kb
input:
4032 >>--->>>>>>>> >->>->->-->->>> >>--->>--->>> >>->->->>>>>>>> >->---->->>> >->>->>---->>>> >>>>>>>>->>>> >->>>--->>>->>> >->>->>-->>>>>> >->>-->---->>> >-->--->>>->>> >->---->>-->>>> >>------>>> >>>-->>--->>>>> >->->->>-->>>> >->->-->>->->>> >>->>>>-->->>>> >>>-->>->--->>> >->->>>>>->>>> >>-->->>...
output:
Yes 5 1 13 1 11 1 8 1 8 2 7 Yes 8 1 15 1 15 1 5 3 13 4 5 6 5 8 6 11 5 Yes 6 1 13 1 13 1 13 2 7 6 8 7 7 Yes 7 1 15 1 13 1 10 1 10 2 5 4 5 6 5 Yes 5 1 12 1 12 1 5 3 8 8 5 Yes 7 1 15 1 14 1 5 3 12 4 5 6 9 7 8 Yes 10 1 13 1 12 1 12 2 11 3 10 4 9 5 8 6 7 7 6 8 5 Yes 9 1 15 1 15 1 5 3 13 4 12 5 7 9 7 10 6...
result:
ok ok (4032 test cases)
Test #4:
score: 0
Accepted
time: 10ms
memory: 3628kb
input:
10000 >>>>->->>->>->>>> >->-->>->>->>>>>> >->->>-->--->>>>> >---->-->->>>>>>> >->-->>--->>->>>> >->>->>>>>>-->>> >>--->->-->>->>> >-->---->>>->>> >->----->->->>>>> >>--->---->-->>>> >>-->->->--->>> >----->>-->>->>>> >-->->->>>>>->>>> >>->>---->-->>> >>->>-->>>-->>> >------>->>>->>>> >->->-->->>>->>>...
output:
Yes 11 1 17 1 16 1 16 2 15 3 14 4 5 6 5 8 9 9 5 11 6 12 5 Yes 9 1 17 1 17 1 14 1 5 3 6 6 9 7 5 9 6 10 5 Yes 7 1 17 1 15 1 5 3 5 5 11 6 6 9 7 Yes 6 1 17 1 16 1 13 1 8 6 6 9 5 Yes 8 1 17 1 16 1 5 3 6 6 11 7 7 11 6 12 5 Yes 11 1 16 1 16 1 5 3 14 4 5 6 11 7 10 8 9 9 8 10 7 11 6 Yes 8 1 16 1 16 1 16 2 7 ...
result:
ok ok (10000 test cases)
Test #5:
score: 0
Accepted
time: 14ms
memory: 3552kb
input:
10000 >>>-->>>>-->---->->->-->>> >>-->>>>->-->>->>> >->-->--->--->->-->>--->>->->>-->->->>>>>>->>>>----->->--->>----->>-->>>----->->->>>--->>->>-->->->->---->>->>>-->>->->>>->->>>>->>->->>-->>>->>->>-->>>>-->>-->>>->>->->>>--->>>-->>>--->>->->>>>>->->---->>>>->>> ->->>>>--->>>>>>->>>->>>>->->-->-->>...
output:
Yes 13 1 26 1 26 1 26 2 25 3 6 6 21 7 20 8 19 9 6 12 8 17 5 19 5 21 6 Yes 11 1 18 1 18 1 18 2 6 5 14 6 13 7 12 8 5 10 6 13 6 14 5 Yes 112 1 211 1 211 1 5 3 6 6 7 10 7 14 5 16 6 19 193 20 7 24 188 25 5 27 5 29 183 30 6 33 5 35 5 37 175 38 174 39 173 40 172 41 171 42 5 44 168 45 167 46 166 47 9 53 5 5...
result:
ok ok (10000 test cases)
Test #6:
score: 0
Accepted
time: 14ms
memory: 3628kb
input:
9999 ->->--->>>>->->--->>-- ->>>--->>>-->>--->>--- -->>>>>>>- >>>->>>>>>>-- >>-->-->->----->->>>>->>->---->-> >-->->>>--->->->>->->- >->--->--->>>>->>>----->------>>-->->>> >>->>>->>>---->>>->>>>>>>>>->--->>->>>>>-->>>->->->>-->->--->->-->->>->->->>-->-->>>>>>>>--->>--->->>>-->->----->>-->->>--->-->...
output:
No No No No No No Yes 16 1 39 1 39 1 5 3 7 7 7 11 29 12 28 13 27 14 5 16 24 17 23 18 9 24 10 31 9 32 6 35 5 Yes 71 1 129 1 129 1 129 2 5 4 126 5 125 6 5 8 122 9 121 10 8 15 115 16 114 17 5 19 111 20 110 21 109 22 108 23 107 24 106 25 105 26 104 27 5 29 7 33 97 34 5 36 94 37 93 38 92 39 91 40 6 43 87...
result:
ok ok (9999 test cases)
Test #7:
score: 0
Accepted
time: 4ms
memory: 5240kb
input:
5 >-->>>>>--->->->>->>>>>->->-->-->->>>-->->--->>>------>->>-->>>------->>---->-->>>>>>-->>--->>-->->->>>>->-->------>>->>>>->>>-->---->--->>-->-->->--->->->->->>->-->->--->>>>->>->--->->>-->>>>>>->>>>->>--->->>-->>->->---->>>->->>->>->--->->->-->->>->->-->->------>>>->>>>>->>-->>->>>->>>>>----->---...
output:
No No Yes 48173 1 95948 1 95948 1 95948 2 95947 3 5 5 95944 6 95943 7 5 9 95940 10 5 12 8 17 95932 18 95931 19 95930 20 5 22 95927 23 95926 24 5 26 95923 27 95922 28 5 30 6 33 95916 34 5 36 95913 37 5 39 95910 40 95909 41 95908 42 5 44 95905 45 95904 46 95903 47 7 51 6 54 9 60 95889 61 95888 62 9588...
result:
ok ok (5 test cases)
Test #8:
score: 0
Accepted
time: 15ms
memory: 6984kb
input:
5 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
No Yes 99997 1 100000 1 99999 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 ...
result:
ok ok (5 test cases)
Test #9:
score: 0
Accepted
time: 212ms
memory: 4092kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 21000 1 25000 1 24998 1 24995 1 24992 1 24989 1 24986 1 24983 1 24980 1 24977 1 24974 1 24971 1 24968 1 24965 1 24962 1 24959 1 24956 1 24953 1 24950 1 24947 1 24944 1 24941 1 24938 1 24935 1 24932 1 24929 1 24926 1 24923 1 24920 1 24917 1 24914 1 24911 1 24908 1 24905 1 24902 1 24899 1 24896 1 ...
result:
ok ok (20 test cases)
Test #10:
score: 0
Accepted
time: 165ms
memory: 4120kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 9852 1 25000 1 24998 1 24995 1 24992 1 24989 1 24986 1 24983 1 24980 1 24977 1 24974 1 24971 1 24968 1 24965 1 24962 1 24959 1 24956 1 24953 1 24950 1 24947 1 24944 1 24941 1 24938 1 24935 1 24932 1 24929 1 24926 1 24923 1 24920 1 24917 1 24914 1 24911 1 24908 1 24905 1 24902 1 24899 1 24896 1 2...
result:
ok ok (20 test cases)
Extra Test:
score: 0
Extra Test Passed