답안 #133156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133156 2019-07-20T08:10:22 Z forelax Jetpack (COCI16_jetpack) C++14
80 / 80
122 ms 10096 KB
#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<<" ";
    }
}

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 ++){
                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 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 760 KB Output is correct
6 Correct 9 ms 936 KB Output is correct
7 Correct 25 ms 2140 KB Output is correct
8 Correct 57 ms 4796 KB Output is correct
9 Correct 88 ms 7260 KB Output is correct
10 Correct 122 ms 10096 KB Output is correct