QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#699700 | #9535. Arrow a Row | ucup-team3646# | AC ✓ | 18ms | 5264kb | C++20 | 2.8kb | 2024-11-02 10:27:02 | 2024-11-02 10:27:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define elif else if
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int,int>
#define repname(a, b, c, d, e, ...) e
#define rep(...) repname(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define rep0(x) for (int rep_counter = 0; rep_counter < (x); ++rep_counter)
#define rep1(i, x) for (int i = 0; i < (x); ++i)
#define rep2(i, l, r) for (int i = (l); i < (r); ++i)
#define rep3(i, l, r, c) for (int i = (l); i < (r); i += (c))
struct ScalarInput {
template<class T>
operator T(){
T ret;
cin >> ret;
return ret;
}
};
struct VectorInput {
size_t n;
VectorInput(size_t n): n(n) {}
template<class T>
operator vector<T>(){
vector<T> ret(n);
for(T &x : ret) cin >> x;
return ret;
}
};
ScalarInput input(){ return ScalarInput(); }
VectorInput input(size_t n){ return VectorInput(n); }
template<typename T>
void print(vector<T> a){
for(int i=0;i<a.size();i++){
cout<<a[i]<<" \n"[i+1==a.size()];
}
}
template<class T>
void print(T x){
cout << x << '\n';
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){
cout << head << ' ';
print(forward<Tail>(tail)...);
}
int dbg=0;
void solve(string s){
int n=s.size();
if(s.substr(n-3,3)!=">>>"){
print("No");
return;
}
if(s[0]!='>'){
print("No");
return;
}
int pos=-1;
rep(i,n){
if(s[i]=='-')pos=i;
}
if(pos==-1){
print("No");
return;
}
// need
vector<pair<int,int>>op;
int l=0;
while(l<pos){
assert(s[l]=='>');
int r=l+1;
while(r<n&&s[r]=='-')r++;
op.push_back({l,max(5,r-l+3)});
l=r;
}
int last=pos;
while(s[last]=='-')last--;
for(int i=n-5;i>=pos;i--){
op.push_back({i,5});
}
op.push_back({last,pos-last+4});
if(dbg){
string t(n,'*');
for(auto [left,len]:op){
cerr<<left<<" "<<len<<endl;
assert(left+len<=n);
assert(len>=5);
t[left]='>';
rep(i,1,len-3)t[left+i]='-';
rep(i,len-3,len)t[left+i]='>';
}
assert(t==s);
print(s,t);
}
print("Yes",op.size());
for(auto [left,len]:op){
print(left+1,len);
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
if(dbg){
for(int n=5;n<10;n++){
rep(bit,1<<n){
string s;
rep(i,n){
if((bit>>i)&1){
s+='>';
}
else{
s+='-';
}
}
solve(s);
}
}
}
int T;
cin>>T;
rep(T){
string s;
cin>>s;
solve(s);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
4 >>->>> >>>-> >>>>> >->>>>>>
output:
Yes 3 1 5 2 5 2 5 No No Yes 5 1 5 4 5 3 5 2 5 1 5
result:
ok ok (4 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
126 >->-->>>> >--->->>>> >--->-->>> >>-->->>> >>-->>>>> >>->->>>> >>->>->>>> >-->->->>> >->->>>>>> >->>> >->->>>>> >>>->->>> >>->>>>>>> >>>>>->>> >->>>->>> >>--->->>> >>->>>> >->>>>->>> >>>>-->>> >---->>> >>>---->>> >>>>->>>> >->>-->>> >-->-->>>> >>---->>> >>--->>> >->>>-->>> >>-->>>> >>---->>>> >>-...
output:
Yes 4 1 5 3 6 5 5 3 6 Yes 4 1 7 5 5 6 5 5 5 Yes 3 1 7 5 6 5 6 Yes 4 1 5 2 6 5 5 5 5 Yes 5 1 5 2 6 5 5 4 5 2 6 Yes 5 1 5 2 5 4 5 5 5 4 5 Yes 6 1 5 2 5 4 5 5 5 6 5 5 5 Yes 4 1 6 4 5 6 5 6 5 Yes 6 1 5 3 5 6 5 5 5 4 5 3 5 Yes 2 1 5 1 5 Yes 5 1 5 3 5 5 5 4 5 3 5 Yes 5 1 5 2 5 3 5 5 5 5 5 Yes 7 1 5 2 5 6 ...
result:
ok ok (126 test cases)
Test #3:
score: 0
Accepted
time: 3ms
memory: 3588kb
input:
4032 >>--->>>>>>>> >->>->->-->->>> >>--->>--->>> >>->->->>>>>>>> >->---->->>> >->>->>---->>>> >>>>>>>>->>>> >->>>--->>>->>> >->>->>-->>>>>> >->>-->---->>> >-->--->>>->>> >->---->>-->>>> >>------>>> >>>-->>--->>>>> >->->->>-->>>> >->->-->>->->>> >>->>>>-->->>>> >>>-->>->--->>> >->->>>>>->>>> >>-->->>...
output:
Yes 8 1 5 2 7 9 5 8 5 7 5 6 5 5 5 2 7 Yes 7 1 5 3 5 4 5 6 5 8 6 11 5 11 5 Yes 5 1 5 2 7 6 5 7 7 7 7 Yes 10 1 5 2 5 4 5 6 5 11 5 10 5 9 5 8 5 7 5 6 5 Yes 4 1 5 3 8 8 5 8 5 Yes 7 1 5 3 5 4 5 6 5 7 8 11 5 7 8 Yes 10 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 8 5 Yes 8 1 5 3 5 4 5 5 7 9 5 10 5 11 5 11 5 Yes 9 ...
result:
ok ok (4032 test cases)
Test #4:
score: 0
Accepted
time: 9ms
memory: 3588kb
input:
10000 >>>>->->>->>->>>> >->-->>->>->>>>>> >->->>-->--->>>>> >---->-->->>>>>>> >->-->>--->>->>>> >->>->>>>>>-->>> >>--->->-->>->>> >-->---->>>->>> >->----->->->>>>> >>--->---->-->>>> >>-->->->--->>> >----->>-->>->>>> >-->->->>>>>->>>> >>->>---->-->>> >>->>-->>>-->>> >------>->>>->>>> >->->-->->>>->>>...
output:
Yes 11 1 5 2 5 3 5 4 5 6 5 8 5 9 5 11 5 12 5 13 5 12 5 Yes 10 1 5 3 6 6 5 7 5 9 5 10 5 13 5 12 5 11 5 10 5 Yes 8 1 5 3 5 5 5 6 6 9 7 13 5 12 5 9 7 Yes 8 1 8 6 6 9 5 13 5 12 5 11 5 10 5 9 5 Yes 8 1 5 3 6 6 5 7 7 11 5 12 5 13 5 12 5 Yes 10 1 5 3 5 4 5 6 5 7 5 8 5 9 5 10 5 11 6 11 6 Yes 7 1 5 2 7 6 5 8...
result:
ok ok (10000 test cases)
Test #5:
score: 0
Accepted
time: 8ms
memory: 3604kb
input:
10000 >>>-->>>>-->---->->->-->>> >>-->>>>->-->>->>> >->-->--->--->->-->>--->>->->>-->->->>>>>>->>>>----->->--->>----->>-->>>----->->->>>--->>->>-->->->->---->>->>>-->>->->>>->->>>>->>->->>-->>>->>->>-->>>>-->>-->>>->>->->>>--->>>-->>>--->>->->>>>>->->---->>>>->>> ->->>>>--->>>>>>->>>->>>>->->-->-->>...
output:
Yes 12 1 5 2 5 3 6 6 5 7 5 8 5 9 6 12 8 17 5 19 5 21 6 21 6 Yes 10 1 5 2 6 5 5 6 5 7 5 8 5 10 6 13 5 14 5 14 5 Yes 111 1 5 3 6 6 7 10 7 14 5 16 6 19 5 20 7 24 5 25 5 27 5 29 5 30 6 33 5 35 5 37 5 38 5 39 5 40 5 41 5 42 5 44 5 45 5 46 5 47 9 53 5 55 7 59 5 60 9 66 5 67 6 70 5 71 5 72 9 78 5 80 5 82 5...
result:
ok ok (10000 test cases)
Test #6:
score: 0
Accepted
time: 9ms
memory: 3908kb
input:
9999 ->->--->>>>->->--->>-- ->>>--->>>-->>--->>--- -->>>>>>>- >>>->>>>>>>-- >>-->-->->----->->>>>->>->---->-> >-->->>>--->->->>->->- >->--->--->>>>->>>----->------>>-->->>> >>->>>->>>---->>>->>>>>>>>>->--->>->>>>>-->>>->->->>-->->--->->-->->>->->->>-->-->>>>>>>>--->>--->->>>-->->----->>-->->>--->-->...
output:
No No No No No No Yes 15 1 5 3 7 7 7 11 5 12 5 13 5 14 5 16 5 17 5 18 9 24 10 31 5 32 6 35 5 35 5 Yes 70 1 5 2 5 4 5 5 5 6 5 8 5 9 5 10 8 15 5 16 5 17 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 29 7 33 5 34 5 36 5 37 5 38 5 39 5 40 6 43 5 44 5 45 5 47 5 49 5 51 5 52 6 55 5 57 7 61 5 63 6 66 5 68...
result:
ok ok (9999 test cases)
Test #7:
score: 0
Accepted
time: 7ms
memory: 4592kb
input:
5 >-->>>>>--->->->>->>>>>->->-->-->->>>-->->--->>>------>->>-->>>------->>---->-->>>>>>-->>--->>-->->->>>>->-->------>>->>>>->>>-->---->--->>-->-->->--->->->->->>->-->->--->>>>->>->--->->>-->>>>>>->>>>->>--->->>-->>->->---->>>->->>->>->--->->->-->->>->->-->->------>>>->>>>>->>-->>->>>->>>>>----->---...
output:
No No Yes 48172 1 5 2 5 3 5 5 5 6 5 7 5 9 5 10 5 12 8 17 5 18 5 19 5 20 5 22 5 23 5 24 5 26 5 27 5 28 5 30 6 33 5 34 5 36 5 37 5 39 5 40 5 41 5 42 5 44 5 45 5 46 5 47 7 51 6 54 9 60 5 61 5 62 5 63 5 64 5 66 5 67 5 68 6 71 5 72 5 73 5 75 5 76 5 77 7 81 5 82 5 83 7 87 5 88 6 91 5 93 5 94 8 99 5 100 8 ...
result:
ok ok (5 test cases)
Test #8:
score: 0
Accepted
time: 15ms
memory: 5264kb
input:
5 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
No Yes 99997 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5 46 5 47 5 48 5 49 5 50 5 51 5 52 5 53 5 54 5 55 5 56 5 57 5 58 5 59 5 6...
result:
ok ok (5 test cases)
Test #9:
score: 0
Accepted
time: 12ms
memory: 3780kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 24995 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5 46 5 47 5 48 5 49 5 50 5 51 5 52 5 53 5 54 5 55 5 56 5 57 5 58 5 59 5 60 5...
result:
ok ok (20 test cases)
Test #10:
score: 0
Accepted
time: 18ms
memory: 3776kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 24997 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5 46 5 47 5 48 5 49 5 50 5 51 5 52 5 53 5 54 5 55 5 56 5 57 5 58 5 59 5 60 5...
result:
ok ok (20 test cases)
Extra Test:
score: 0
Extra Test Passed