QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#846647 | #9926. Flipping Paths | eastcloud | WA | 4ms | 3820kb | C++23 | 1.9kb | 2025-01-07 11:28:33 | 2025-01-07 11:28:35 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array
#define eb emplace_back
#define IL inline
#define For(i,j,k) for(int i=(j);i<=(k);i++)
#define Fol(i,k,j) for(int i=(k);i>=(j);i--)
using namespace std;
#define N 205
int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
void write(int x){
if(x<0)x=-x,putchar('-');
if(x/10)write(x/10);
putchar(x%10+'0');
}
void debug(auto &&...x){
((cerr<<x<<' '),...);
cerr<<'\n';
}
char s[N][N];
int a[N][N];
int n,m;
bool check(char t){
For(i,1,n)For(j,1,m)a[i][j]=(s[i][j]==t);
vector<string> res;
For(_,1,401){
string now="";int pos=1,flag=0;
For(i,1,n)For(j,1,m)if(a[i][j]==1)flag=1;
if(!flag)break;
if(_==401)return false;
For(i,1,n){
int step=pos;a[i][pos]^=1;
Fol(j,m,pos+1)if(a[i][j]){step=j;break;}
while(pos<step){pos++;a[i][pos]^=1;now+='R';}
if(i!=n)now+='D';
}
while(pos+1<=m){pos++;now+='R';}
res.pb(now);
}
cout<<"YES"<<endl;
cout<<res.size()<<endl;
for(auto v:res)cout<<v<<endl;
return true;
}
void solve(){
n=read(),m=read();
For(i,1,n)scanf("%s",s[i]+1);
if(check('W'))return;
if(check('B'))return;printf("NO\n");
}
int main(){
#ifdef EAST_CLOUD
freopen("a.in","r",stdin);
//freopen("a.out","w",stdout);
#endif
int T=read();while(T--)solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3760kb
input:
4 3 3 WBB BWB BBW 1 5 WWWWW 2 2 BB BB 4 1 W B B W
output:
YES 2 RRDD DDRR YES 1 RRRR YES 0 NO
result:
ok ok (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 4ms
memory: 3820kb
input:
323 1 2 BB 1 2 BW 1 2 WB 1 2 WW 2 1 B B 2 1 B W 2 1 W B 2 1 W W 1 3 BBB 1 3 BBW 1 3 BWB 1 3 BWW 1 3 WBB 1 3 WBW 1 3 WWB 1 3 WWW 2 2 BB BB 2 2 BB BW 2 2 BB WB 2 2 BB WW 2 2 BW BB 2 2 BW BW 2 2 BW WB 2 2 BW WW 2 2 WB BB 2 2 WB BW 2 2 WB WB 2 2 WB WW 2 2 WW BB 2 2 WW BW 2 2 WW WB 2 2 WW WW 3 1 B B B 3 ...
output:
YES 0 YES 2 R R YES 1 R YES 1 R YES 0 NO NO YES 1 D YES 0 YES 2 RR RR YES 2 RR RR YES 2 RR RR YES 1 RR YES 3 RR RR RR YES 1 RR YES 1 RR YES 0 YES 2 DR DR YES 1 RD YES 3 RD DR DR YES 1 DR YES 1 DR YES 2 RD DR YES 2 RD DR YES 2 RD DR YES 2 RD DR YES 1 DR YES 1 DR YES 3 RD DR DR YES 1 RD YES 2 DR DR YE...
result:
wrong answer cell (1,2) contains different color with (1,1) after all ops. (test case 2)