# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
167227 | PedroBigMan | Jetpack (COCI16_jetpack) | C++14 | 102 ms | 19516 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF ((ll) pow(2,63) -1)
#define si signed
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
ll N; vector<vector<ll> > f; vector<pl> cur; bool done; vector<vector<bool> > visited;
void Endgame()
{
vector<bool> t;
REP(i,0,N-1) {t.pb(false);}
REP(i,1,N)
{
if(cur[i-1].ff==0)
{
if(cur[i].ff==0) {t[i-1]=true;}
}
else
{
if(cur[i]<cur[i-1]) {t[i-1]=true;}
}
}
vector<pl> ans;
ll curs=0; ll fm=-1;
REP(i,0,N-1)
{
if(t[i])
{
if(curs==0)
{
curs++;
fm=i;
}
else
{
curs++;
}
}
else
{
if(curs>0)
{
ans.pb(mp(fm,curs));
curs=0;
}
}
}
if(curs>0) {ans.pb(mp(fm,curs));}
cout<<ans.size()<<endl;
REP(i,0,ans.size())
{
cout<<ans[i].ff<<" "<<ans[i].ss<<endl;
}
}
void DFS(ll x, ll y)
{
if(visited[x][y]) {return;}
visited[x][y]=true;
if(done) {return;}
cur.pb(mp(x,y));
if(y==N-1)
{
done=true;
Endgame();
return;
}
else
{
pl adj;
adj.ss=y+1;
adj.ff=max(0LL,x-1);
if(f[adj.ff][adj.ss]==0) {DFS(adj.ff,adj.ss);}
adj.ff=min(9LL,x+1);
if(f[adj.ff][adj.ss]==0) {DFS(adj.ff,adj.ss);}
}
cur.pop_back();
return;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
done=false;
cin>>N;
vector<bool> gaypim; REP(i,0,N) {gaypim.pb(false);}
REP(i,0,10) {visited.pb(gaypim);}
vector<ll> xx; REP(i,0,N) {xx.pb(0);}
REP(i,0,10) {f.pb(xx);}
char curc;
REP(i,0,10)
{
REP(j,0,N)
{
cin>>curc;
if(curc=='X') {f[i][j]=1;}
}
}
DFS(9LL,0LL);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |