# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167226 | PedroBigMan | Jetpack (COCI16_jetpack) | C++14 | 1074 ms | 18800 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
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(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<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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |