QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#843899 | #8935. Puzzle: Easy as Scrabble | fryan | WA | 40ms | 46508kb | C++20 | 2.1kb | 2025-01-05 06:54:34 | 2025-01-05 06:54:34 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
#define int long long
const int mxn=1e3+5;
int n,m,x[mxn][mxn],u[mxn][mxn],l[mxn][mxn],r[mxn][mxn],d[mxn][mxn];
char a;
void push(int x, int y) {
if (u[x][y]) {
if (x+1==n) {
cout<<"NO";
exit(0);
}
swap(u[x][y],u[x+1][y]);
}
if (l[x][y]) {
if (y+1==m) {
cout<<"NO\n";
exit(0);
}
swap(l[x][y],l[x][y+1]);
}
if (r[x][y]) {
if (y-1==0) {
cout<<"NO\n";
exit(0);
}
swap(r[x][y],r[x][y-1]);
}
if (d[x][y]) {
if (x-1==0) {
cout<<"NO\n";
exit(0);
}
swap(d[x][y],d[x-1][y]);
}
}
bool ok(int x, int y) {
int c = max(max(u[x][y],l[x][y]),max(r[x][y],d[x][y]));
if (u[x][y] && u[x][y] != c) return 0;
if (l[x][y] && l[x][y] != c) return 0;
if (r[x][y] && r[x][y] != c) return 0;
if (d[x][y] && d[x][y] != c) return 0;
if (c && ::x[x][y]) return 0;
if (l[x][y] && r[x][y] && l[x][y]!=r[x][y]) {
cout<<"NO\n";
exit(0);
}
if (u[x][y] && d[x][y] && u[x][y]!=d[x][y]) {
cout<<"NO\n";
exit(0);
}
return 1;
}
queue<int> qx,qy;
void p() {
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
int c = max(max(u[i][j],l[i][j]),max(r[i][j],d[i][j]));
cout<<(char)(c+'.')<<"";
}
cout<<'\n';
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin>>n>>m;
cin>>a;
for (int i=0; i<m; i++) {
cin>>a; u[0][i] = a-'.';
}
cin>>a;
for (int i=0; i<n; i++) {
cin>>a;
l[i][0] = a-'.';
for (int j=0; j<m; j++) {
cin>>a;
x[i][j] = (a=='x');
qx.push(i);
qy.push(j);
}
cin>>a;
r[i][m-1] = a-'.';
}
cin>>a;
for (int i=0; i<m; i++) {
cin>>a;
d[n-1][i] = a-'.';
}
while (sz(qx)) {
int x = qx.front(); qx.pop();
int y = qy.front(); qy.pop();
if (x<0 || x>=n || y<0 || y>=m) continue;
if (ok(x,y)) continue;
push(x,y);
qx.push(x-1); qy.push(y);
qx.push(x+1); qy.push(y);
qx.push(x); qy.push(y+1);
qx.push(x); qy.push(y-1);
}
cout<<"YES\n";
p();
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 12000kb
input:
5 5 .CBA... ....x.. ..x...C A.....B B..x..A C...... .......
output:
YES CBA.. ....C A...B B...A C....
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 11664kb
input:
1 2 .... Nx.. ..O.
output:
NO
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 2ms
memory: 11748kb
input:
5 5 .U.N.X. U....xX Ox....X M...xxN Vx....S Ix.x..X ..IBHX.
output:
YES U.NX. .O..X M.N.. .VB.S .I.HX
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 0ms
memory: 11828kb
input:
10 10 .BAZEMIEKUJ. A..........K B..x.x.x..x. K.........xT A.x..x.....J Hx....x....B Q..x....x.xW S...x......W S...x.xxx..Z ...x......xZ I..x..x.x.xR .QKO.ID..RW.
output:
YES .AZEMIEK.. B.......U. K.......T. A........J .H.......B Q.......W. S........W S.O.....Z. QK...D..Z. ...II...R.
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 0ms
memory: 11732kb
input:
5 10 .PTWIVVISPY. T...x.x....Y Xx.x.xx..x.K P.x.xx.....K S..........A E.........xS .SPEASDCYSA.
output:
YES .TW.V.ISPY .X.I.....K P....V...K SP.......A ..EASDCYS.
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 2ms
memory: 11676kb
input:
10 5 .HVYN.. Y.x...C V..x..B H...x.Z ....xxN ....x.P B.x...G Fx.x..D Txx..xK E..x.xR Sx....B .EPSBD.
output:
YES ..YNC .V..B H...Z ..N.. ....P B...G .F..D ..TK. EP.R. ..SB.
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 0ms
memory: 11788kb
input:
50 50 .YDOGQIDENEUMONVSGZNMNHLEZCXIRMK.OOCKJOKXXZDUFEMPXS. Y.x...x.x.x..x..........x.......x......x.....x....xX N.........x.....x.....x....x.x.xxxxx.x...x.........E U.....x.....x....x......x.....x........x..........xS ...x......x........x..x.....x.x.x........x.x.x.....S Q.....x.x..x..........x....x....
output:
YES Y.OGQ.D.N.UM.NVSGZNMNHL.ZCXIRMK.OOCKJO.XXZDU.EMPX. ND...I.E....O..........E..............K.....F...E. U........E......................................S. .................................................S Q................................................L F...........................................
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 2ms
memory: 14032kb
input:
100 100 .NUXAMX.LNWZKRRKZIRNZVDJF.XRB.VEFQXHTGLGIKZYSRPPF.YGVTOSQCADEG.KYKH.NWWO.XDXJW.G.RBHABFLWHFVUNOLBHMKN. U..x...x...x....xx........x.....x.....xxx..x..........x..x...x..xx..x..x..x............x.....x.....x.N C...x.......x.............x....x.x.x..x........x..x.xx..x..xx.................x..........
output:
YES .U.AMX.LNW.KRRK..RNZVDJF..RB.VE.QXHTG...KZ.SRPPF.YGVT.SQ.ADE..K..H..WW..X.XJW.G.RBHABF.WHFVU.OLBHM.N .CX.......Z....ZI..............F......GI..Y..........O..C...G..YK..N..O..D..................N.....KO .O...................................L...........................................................
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 10ms
memory: 29916kb
input:
500 500 ..FHFDLGFGHREQBGILNRAGJ.ERZSAFGLQ.ESEBI.ELKM.RENLNFQSPT.TXUEIKHHOQWABSELMOPGTFGTXGYMTSU.N.O.AX.OGNSWTFSLUIMTUX.RUCECKZCXOJNPTFVAJUJTF.LHXURYIQIJCVWDBVZ.ZXFRAT.XIPXTDCSLHJHSZCW.RMNUGPIHYUQYUYAY.NHCBU.JPMLG.DDXAJWKNZJVKNAWAJZAHW.FCBEVATZ.YZ.HQ..QPLFARSHNP..EDPIKLYLF.FIFXEXR.XSUORAP.CZPMJXPUS.W...
output:
YES ...FDL...HREQ..ILNRA...ERZSA.GL...SE.I..LK...ENLNFQS.T.TX.E.K.HOQWA.SE.M.PGTFG.XGY..SU...O.AX.OGNS.TFSLUIM.UX...CEC..CXOJNPT.VA..JTF.LHXURYIQI.CVWDB.Z..XFR.T..IPXTD..LHJHSZCW.RMNUGPIHYUQY.YA..N.CB..JPM.G.DD.AJW.NZJ...AWAJZAHW.FCB...T..YZ.HQ..Q.LFA.S.NP..EDPI.LYLF..IFXEX...SUO.AP.CZP.JXPUS.W.D.WU...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 40ms
memory: 46508kb
input:
1000 1000 .SKFDQ.AV.GPTHMF.PL.YOQRQOXDOF.XVZ.H.MYOJIYT.QZNJQI.ZZMAJ.OAWBJBRXFW.CLEPPKGGAWGTVBKOBL.GPCO.ML.DBL.A.RJ..GF.EHK.CDXLLTCBCL.CGYJBMUSPIN.QELGYW.JE..CFVQF.LVYLFHYJ.MY.FZ.RU.ODLAYTWIZQOQZXBW.BVD.RFPLHLEHAU.G.PLFWFUKA.RSG..AVU.SA.PWRGJYO.OXD..S.Z.LIIADT.YXH..NHWXY.R.YFLS.URIJGPPURZPPVHJFLMKTDT...
output:
YES S.FDQ.AV.GPTHMF.P..YOQRQOXD.F.XV.....YO.IYT.QZ.JQI.ZZMAJ.OAWBJBRX...C.EPP.GGAWGT.B..BL.GPCO.ML.D.L.A.R...GF.E.K.CDXLLT.BCL.CGYJB.USPIN..EL..W.J...CFVQ..LV.LFHYJ.MY.FZ.R..ODLAYTWIZQO.ZX.W...D.R..LHLE.A..G.PLFWFUKA.R.G..A...SA..WRGJ...OXD....Z.L.I.DT.Y.H..N.WXY.R.Y.LS..RI.G.PU.ZP.V..FLMKT.TWI.ZKHZ...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 2ms
memory: 11732kb
input:
1 1000 .K.CCS...LC.....Y..J...E.W.B..Q..KQ...Q...L..U.XSWX..NB..K.OLF...Y.A....HG....RRQO..Y...J.LOS...IN..C......H......X.....B.B.PQRT....VB.........P...E....MF.E...RH.XADCQN.D.KT.W..XNI..PH.Q.L.H..G...ZJR.V.I.......O......J.X..N..QS......UN....HLS..Z..N....X.YH.W..E.Z..JHSAV......YXT.P..TX.WT.SHE....
output:
YES K.CCS...LC.Y.W.Y..J...E.W.B..Q..KQ..EQD..LT.U.XSWX..NB..K.OLF...Y.A....HG.BH.RRQO..Y..PJ.LOSU..IN..C......H......X.....B.B.PQRT...QVB...V..K..P...E....MF.E...RH.XADCQN.D.KT.W..XNI..PH.Q.L.H..G..ZZJR.V.I.......O.....DJ.X..NC.QS......UN....HLS.TZ..N....X.YH.W..EBZZ.JHSAV......YXT.P..TX.WT.SHE...YG...
result:
ok Correct.
Test #12:
score: -100
Wrong Answer
time: 0ms
memory: 12020kb
input:
2 1000 .D..JPYBD.H..F.I.NTFC.VJKS..Q.PBW..XLW.ZS..ATCTMPPKRK.V.NN.MPE.SPN.QODI.H...OR.V..INXOZMGF.KIS.GANJ.WV.YLALHHXO..M.TMTJ..XYP.N.BUENZCUA.I.XJO.Q.NVG.B.TXNI.TVLY.N.CWE.ZEO.ANYRZ.W.PQI.LORBYIYJIK.JZ.PENB.HPJPTIIGVOMF.RPZ..WFM.IS..H..U.ZEX.DXZU.YHM.UOMPOHV.HW..SZ.RHWXW.SZH.....R.X.R.L.JRYLL.CE.IE...
output:
NO
result:
wrong answer Jury has answer but participant has not.