답안 #49503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49503 2018-05-30T01:18:22 Z lcs147 Jetpack (COCI16_jetpack) C++
72 / 80
1000 ms 7960 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
    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:24: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:25:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<res.size();i++){
                 ~^~~~~~~~~~~
jetpack.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
jetpack.cpp:20: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 4 ms 504 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 2 ms 740 KB Output is correct
4 Correct 3 ms 800 KB Output is correct
5 Correct 3 ms 872 KB Output is correct
6 Correct 30 ms 1172 KB Output is correct
7 Correct 161 ms 2076 KB Output is correct
8 Correct 491 ms 3844 KB Output is correct
9 Execution timed out 1068 ms 4248 KB Time limit exceeded
10 Correct 22 ms 7960 KB Output is correct