#include<bits/stdc++.h>
using namespace std;
int main(){
int r=10,c;
cin>>c;
vector<vector<char> > ch(r,vector<char> (c));
vector<vector<int> > v(r,vector<int> (c,-1));
vector<vector<int> > st(r,vector<int> (c));
for(int i = 0 ; i < r ; i ++){
for(int j = 0 ; j < c ; j ++){
cin>>ch[i][j];
}
}
for(int i = 0 ; i < r ; i ++)
if(ch[i][c-1]=='.'){
v[i][c-1]=min(i+1,r-1);
st[i][c-1]=1;
}
for(int j = c-2 ; j >= 0 ; j --){
for(int i = 0 ; i < r ; i ++){
if(ch[i][j]=='X')continue;
int p1=min(r-1,i+1);
int p2=max( 0 ,i-1);
if(v[p1][j+1]!=-1){
v[i][j]=p1;
st[i][j]=1;
}else if(v[p2][j+1]!=-1){
v[i][j]=p2;
st[i][j]=2;
}
}
}
// for(int i = 0 ; i < r ; i ++){
// for(int j = 0 ; j < c ; j ++){
// cout<<v[i][j]<<" ";
// }
// cout<<endl;
// }
// for(int i = 0 ; i < r ; i ++){
// for(int j = 0 ; j < c ; j ++){
// cout<<st[i][j]<<" ";
// }
// cout<<endl;
// }
vector<int> ast(c);
for(int i = 0,cr=9 ; i < c ; i ++){
ast[i]=st[cr][i]-1;
cr=v[cr][i];
}
vector<pair<int,int> > rz;
for(int i = 0,j ; i < c ; i ++){
if(ast[i]){
for(j = i ; j<c&&ast[j] ; j ++);
rz.push_back({i,j-i});
i=j;
}
}
cout<<rz.size()<<endl;
for(int i = 0 ; i < rz.size() ; i ++){
cout<<rz[i].first<<" "<<rz[i].second<<endl;
}
}
Compilation message
jetpack.cpp: In function 'int main()':
jetpack.cpp:59:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ; i < rz.size() ; i ++){
~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
764 KB |
Output is correct |
6 |
Correct |
10 ms |
888 KB |
Output is correct |
7 |
Correct |
30 ms |
2296 KB |
Output is correct |
8 |
Correct |
69 ms |
5308 KB |
Output is correct |
9 |
Correct |
111 ms |
8024 KB |
Output is correct |
10 |
Correct |
170 ms |
11196 KB |
Output is correct |