Submission #725837

#TimeUsernameProblemLanguageResultExecution timeMemory
725837YugiHackerJetpack (COCI16_jetpack)C++14
80 / 80
28 ms6612 KiB
/* www.youtube.com/YugiHackerChannel oj.vnoi.info/user/YugiHackerKhongCopCode */ #include<bits/stdc++.h> #define el cout<<"\n" #define f0(i,n) for(int i=0;i<n;++i) #define f1(i,n) for(int i=1;i<=n;++i) #define maxn 100005 #define pii pair<int,int> #define fi first #define se second using namespace std; int n, d[12][maxn], r; char a[12][maxn]; queue <pii> q; main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; f1 (i, 10) f1 (j, n) cin >> a[i][j]; q.push({10, 1}); while (q.size()) { int u = q.front().fi, v = q.front().se; if (v == n) r = u; q.pop(); int u_up = max(1, u-1); int u_down = min(10, u+1); if (a[u_up][v+1] == '.' && d[u_up][v+1] == 0) { q.push({u_up, v+1}); d[u_up][v+1] = u; } if (a[u_down][v+1] == '.' && d[u_down][v+1] == 0) { q.push({u_down, v+1}); d[u_down][v+1] = u; } } //f1 (i, 10) {f1 (j, n) if (d[i][j]) cout << '*'; else cout << '.'; el;} vector <pii> ans; for (int i=n; i; i--) { int cnt = 0; //cout << r << ' ' << i, el; while (d[r][i] == r+1 || (r == 1 && d[r][i] == 1)) { ++cnt; r = d[r][i]; //cout << r << ' ' << i, el; i--; } if (cnt) ans.push_back({i-1, cnt}); r = d[r][i]; } reverse(ans.begin(), ans.end()); cout << ans.size(), el; for (auto p:ans) cout << p.fi << ' ' << p.se, el; }

Compilation message (stderr)

jetpack.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...