Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
314949 admin_wgf [ 2022年绍兴市第二十届少儿信息学竞赛复赛 ] -华容道(huarong) C++ 通过 100 1 MS 252 KB 599 2025-03-28 20:24:19

Tests(9/9):


#include <bits/stdc++.h> using namespace std; int a[5][5]; int main(){ int n,x=3,y=3,t=1; string s; cin>>n>>s; for(int i=1; i<=3; i++){ for(int j=1; j<=3; j++){ a[i][j]=t; t++; } } a[3][3]=0; for(int i=n-1;i>=0;i--){ if(s[i]=='L'){ swap(a[x][y+1],a[x][y]); y++; }else if(s[i]=='R'){ swap(a[x][y-1],a[x][y]); y--; }else if(s[i]=='U'){ swap(a[x+1][y],a[x][y]); x++; }else{ swap(a[x-1][y],a[x][y]); x--; } } for(int i=1;i<=3;i++){ for(int j=1;j<=3;j++){ cout<<a[i][j]<<" "; } cout<<"\n"; } return 0; }


测评信息: