답안 #333342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333342 2020-12-05T16:31:38 Z JovanK26 Jetpack (COCI16_jetpack) C++14
80 / 80
16 ms 5104 KB
#include <bits/stdc++.h>

using namespace std;
int n;
char mat[10][100001];
vector<int> v;
bool dfs(int x,int y)
{
    if(mat[x][y]=='X')return 0;
    if(y==n-1)return 1;
    mat[x][y]='X';
    if(dfs(min(9,x+1),y+1))return 1;
    if(dfs(max(0,x-1),y+1))
    {
        v.push_back(y);
        return 1;
    }
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i=0;i<10;i++)
    {
        cin >> mat[i];
    }
    dfs(9,0);
    reverse(v.begin(),v.end());
    cout << v.size()<<'\n';
    for(int i=0;i<v.size();i++)
    {
        cout << v[i]<<' '<<1<<'\n';
    }
    return 0;
}

Compilation message

jetpack.cpp: In function 'int main()':
jetpack.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 620 KB Output is correct
7 Correct 3 ms 1260 KB Output is correct
8 Correct 6 ms 2540 KB Output is correct
9 Correct 9 ms 3692 KB Output is correct
10 Correct 16 ms 5104 KB Output is correct