답안 #49504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49504 2018-05-30T01:20:53 Z lcs147 Jetpack (COCI16_jetpack) C++
80 / 80
18 ms 5276 KB
#include<bits/stdc++.h>
using namespace std;
vector<int>res;
char tab[20][100010];
int n;
int dfs(int l,int c){
    if(tab[l][c]=='X')return 0;
    if(c==n-1)return 1;
    // desce
    tab[l][c]='X';
    if(dfs(min(9,l+1),c+1) == 1) return 1;
    else if(dfs(max(0,l-1),c+1) == 1){
        res.push_back(c);
        return 1;
    }
    return 0;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<10;i++){
        scanf(" %s",tab[i]);
    }
    dfs(9,0);
    reverse(res.begin(),res.end());
    printf("%d\n",res.size());
    for(int i=0;i<res.size();i++){
        printf("%d %d\n",res[i],1);
    }
    return 0;
}

Compilation message

jetpack.cpp: In function 'int main()':
jetpack.cpp:25:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",res.size());
                   ~~~~~~~~~~^
jetpack.cpp:26:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<res.size();i++){
                 ~^~~~~~~~~~~
jetpack.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
jetpack.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s",tab[i]);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 2 ms 736 KB Output is correct
7 Correct 4 ms 1436 KB Output is correct
8 Correct 7 ms 2832 KB Output is correct
9 Correct 11 ms 3924 KB Output is correct
10 Correct 18 ms 5276 KB Output is correct