| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1343908 | coderg300711 | Jetpack (COCI16_jetpack) | C++20 | 12 ms | 11768 KiB |
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define pb push_back
#define sz(x) (int)(x).size()
#define rsz resize
#define ass assign
void setIO(string name = ""){if(name.size()){ freopen((name + ".in").c_str(), "r", stdin);freopen((name + ".out").c_str(), "w", stdout);}}
#define F(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
//template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define each(a,x) for(auto a:x)
#define FOR(i,a) for(int i=0;i<(a);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define eb emplace_back
#define ft front()
#define V vector
const int maxn=100005;
const int mod=1e9+7;
const int mox=10000005;
const int inf=1e9;
bool reachable[10][maxn];
ll prev_row[10][maxn];
char move_made[10][maxn];
void solve(){
int n;
cin>>n;
V<string> g(10);
FOR(i,10)cin>>g[i];
reachable[9][0]=1;
FOR(c,n-1){
FOR(r,10){
if(!reachable[r][c])continue;
int nr_up=max(0,r-1);
if(g[nr_up][c+1]!='X'){
reachable[nr_up][c+1]=1;
prev_row[nr_up][c+1]=r;
move_made[nr_up][c+1]='U';
}
int nr_down=min(9,r+1);
if(g[nr_down][c+1]!='X'){
reachable[nr_down][c+1]=1;
prev_row[nr_down][c+1]=r;
move_made[nr_down][c+1]='D';
}
}
}
int curr=-1;
FOR(r,10){
if(reachable[r][n-1]){
curr=r;
break;
}
}
if(curr==-1)return;
string path="";
ROF(c,1,n){
path+=move_made[curr][c];
curr=prev_row[curr][c];
}
reverse(path.begin(),path.end());
V<pii> res;
int len=sz(path),i=0;
while(i<len){
if(path[i]=='U'){
int st=i;
while(i<len && path[i]=='U')i++;
res.pb(mp(st,i-st));
}else i++;
}
cout<<sz(res)<<'\n';
FOR(i,sz(res))cout<<res[i].fi<<' '<<res[i].se<<'\n';
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);
//#ifndef ONLINE_JUDGE
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
//#endif
// setIO("");
int tt=1;
//cin>>tt;
while(tt--)solve();
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
