Submission #167226

#TimeUsernameProblemLanguageResultExecution timeMemory
167226PedroBigManJetpack (COCI16_jetpack)C++14
72 / 80
1074 ms18800 KiB
#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)

jetpack.cpp: In function 'void Out(std::vector<long long int>)':
jetpack.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
jetpack.cpp:20:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
jetpack.cpp:20:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
jetpack.cpp: In function 'void Endgame()':
jetpack.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
jetpack.cpp:65:9:
     REP(i,0,ans.size())
         ~~~~~~~~~~~~~~           
jetpack.cpp:65:5: note: in expansion of macro 'REP'
     REP(i,0,ans.size())
     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...