QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#718406 | #9535. Arrow a Row | CodeChild# | AC ✓ | 17ms | 5132kb | C++20 | 2.1kb | 2024-11-06 20:25:41 | 2024-11-06 20:25:42 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <cstdio>
#include <unordered_map>
#include <deque>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <array>
#include <bitset>
#include <limits.h>
#include <numeric>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll ;
typedef pair<int,int> PII;
typedef pair<int,LL> PIL;
typedef pair<int ,PII> PIII ;
typedef pair<int, pair<PII ,int > > PIIII;
typedef pair<LL , LL> PLL ;
typedef pair<LL ,int > PLI ;
typedef pair<int,char > PIC ;
typedef unsigned long long ULL ;
const int N = 5e5+10,M = 4e5+10 ;
const LL mod = 1e9+7 , INF = 1e18+10;
const int inf = 1e8 ;
const double eps = 1e-7 ;
const ULL P= 131 ;
// LL n , m , k ;
void solve( ) {
string s ;
cin >> s ;
int n = s.size() ;
if( s[0] != '>' || s[n-3] == '-' || s[n-2] == '-' || s[n-1] == '-' ) {
cout <<"No\n" ;return ;
}
bool f = false ;
for(auto ch : s ) f |= ch == '-' ;
if( !f ) {
cout <<"No\n" ;return ;
}
vector< array<int,2>> a ;
for(int i = 0 ; i < n ; ++ i ) {
int j = i + 1 ;
while( j < n && s[i] == s[j] ) ++ j ;
a.push_back( { i + 1 , j }) ;
i = j - 1 ;
}
vector< array<int,2>> ans , tmp;
for(int i = 0 ; i + 1 < a.size() ; i += 2 ) {
auto [ L , R ] = a[i] ;
for(int j = L ; j <= R ; ++ j )
ans.push_back( { j , j + 4 }) ;
ans.pop_back() ;
ans.push_back( { R , a[i+1][1] + 3 } ) ;
}
auto [ L , R ] = ans.back() ; ans.pop_back() ;
for(int i = R ; i - n < 3 ; i += 3 ) {
tmp.push_back({ L , min( i , n) }) ;
}
reverse( tmp.begin() ,tmp.end()) ;
for(auto [ l , r ] : tmp ) ans.push_back( { l ,r }) ;
cout <<"Yes " << ans.size() << '\n';
for(auto [ l , r ] : ans ) cout << l <<" " << r - l + 1 << '\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie( 0 ) ; cout.tie(0) ;
int T = 1 ;
cin >> T ;
while(T-- ){
solve() ;
}
return 0 ;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
4 >>->>> >>>-> >>>>> >->>>>>>
output:
Yes 2 1 5 2 5 No No Yes 2 1 8 1 5
result:
ok ok (4 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3532kb
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 5 2 6 5 5 Yes 3 1 5 2 8 2 6 Yes 4 1 5 2 5 4 6 4 5 Yes 5 1 5 2 5 4 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 5 2 5 3 5 5 5 Yes 4 1 5 2 9 2 8 2 5 Yes 5 1 5 2 5 3 5 4 5 5 5 Yes 4 1 5 3 5 4 5 5 5 Yes 3 1 5 ...
result:
ok ok (126 test cases)
Test #3:
score: 0
Accepted
time: 4ms
memory: 3540kb
input:
4032 >>--->>>>>>>> >->>->->-->->>> >>--->>--->>> >>->->->>>>>>>> >->---->->>> >->>->>---->>>> >>>>>>>>->>>> >->>>--->>>->>> >->>->>-->>>>>> >->>-->---->>> >-->--->>>->>> >->---->>-->>>> >>------>>> >>>-->>--->>>>> >->->->>-->>>> >->->-->>->->>> >>->>>>-->->>>> >>>-->>->--->>> >->->>>>>->>>> >>-->->>...
output:
Yes 4 1 5 2 12 2 10 2 7 Yes 6 1 5 3 5 4 5 6 5 8 6 11 5 Yes 4 1 5 2 7 6 5 7 7 Yes 6 1 5 2 5 4 5 6 10 6 8 6 5 Yes 3 1 5 3 8 8 5 Yes 6 1 5 3 5 4 5 6 5 7 9 7 8 Yes 9 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 6 8 5 Yes 7 1 5 3 5 4 5 5 7 9 5 10 5 11 5 Yes 6 1 5 3 5 4 5 6 5 7 9 7 6 Yes 4 1 5 3 5 4 6 7 8 Yes 5 1 6 4 7 ...
result:
ok ok (4032 test cases)
Test #4:
score: 0
Accepted
time: 10ms
memory: 3628kb
input:
10000 >>>>->->>->>->>>> >->-->>->>->>>>>> >->->>-->--->>>>> >---->-->->>>>>>> >->-->>--->>->>>> >->>->>>>>>-->>> >>--->->-->>->>> >-->---->>>->>> >->----->->->>>>> >>--->---->-->>>> >>-->->->--->>> >----->>-->>->>>> >-->->->>>>>->>>> >>->>---->-->>> >>->>-->>>-->>> >------>->>>->>>> >->->-->->>>->>>...
output:
Yes 10 1 5 2 5 3 5 4 5 6 5 8 5 9 5 11 5 12 6 12 5 Yes 7 1 5 3 6 6 5 7 5 9 5 10 8 10 5 Yes 6 1 5 3 5 5 5 6 6 9 9 9 7 Yes 5 1 8 6 6 9 9 9 8 9 5 Yes 7 1 5 3 6 6 5 7 7 11 5 12 6 12 5 Yes 9 1 5 3 5 4 5 6 5 7 5 8 5 9 5 10 5 11 6 Yes 6 1 5 2 7 6 5 8 6 11 5 12 5 Yes 5 1 6 4 8 9 5 10 5 11 5 Yes 5 1 5 3 9 9 5...
result:
ok ok (10000 test cases)
Test #5:
score: 0
Accepted
time: 14ms
memory: 3620kb
input:
10000 >>>-->>>>-->---->->->-->>> >>-->>>>->-->>->>> >->-->--->--->->-->>--->>->->>-->->->>>>>>->>>>----->->--->>----->>-->>>----->->->>>--->>->>-->->->->---->>->>>-->>->->>>->->>>>->>->->>-->>>->>->>-->>>>-->>-->>>->>->->>>--->>>-->>>--->>->->>>>>->->---->>>>->>> ->->>>>--->>>>>>->>>->>>>->->-->-->>...
output:
Yes 11 1 5 2 5 3 6 6 5 7 5 8 5 9 6 12 8 17 5 19 5 21 6 Yes 9 1 5 2 6 5 5 6 5 7 5 8 5 10 6 13 5 14 5 Yes 110 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 83 5 84 7 ...
result:
ok ok (10000 test cases)
Test #6:
score: 0
Accepted
time: 14ms
memory: 3776kb
input:
9999 ->->--->>>>->->--->>-- ->>>--->>>-->>--->>--- -->>>>>>>- >>>->>>>>>>-- >>-->-->->----->->>>>->>->---->-> >-->->>>--->->->>->->- >->--->--->>>>->>>----->------>>-->->>> >>->>>->>>---->>>->>>>>>>>>->--->>->>>>>-->>>->->->>-->->--->->-->->>->->->>-->-->>>>>>>>--->>--->->>>-->->----->>-->->>--->-->...
output:
No No No No No No Yes 14 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 Yes 69 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 5 69...
result:
ok ok (9999 test cases)
Test #7:
score: 0
Accepted
time: 12ms
memory: 4652kb
input:
5 >-->>>>>--->->->>->>>>>->->-->-->->>>-->->--->>>------>->>-->>>------->>---->-->>>>>>-->>--->>-->->->>>>->-->------>>->>>>->>>-->---->--->>-->-->->--->->->->->>->-->->--->>>>->>->--->->>-->>>>>>->>>>->>--->->>-->>->->---->>>->->>->>->--->->->-->->>->->-->->------>>>->>>>>->>-->>->>>->>>>>----->---...
output:
No No Yes 48171 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: 17ms
memory: 5132kb
input:
5 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
No Yes 99996 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: 15ms
memory: 3840kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 20999 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: 11ms
memory: 3740kb
input:
20 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
output:
Yes 9851 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