QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#614614 | #8935. Puzzle: Easy as Scrabble | treasuresgc | WA | 23ms | 5688kb | C++23 | 2.7kb | 2024-10-05 16:41:25 | 2024-10-05 16:41:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int sum=0,f=1;
char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}
while(isdigit(ch)){sum=sum*10+ch-48;ch=getchar();}
return sum*f;
}
inline char gc()
{
char ch=getchar();
while(ch!='x'&&ch!='.'&&!isupper(ch)) ch=getchar();
return ch;
}
char a[1005][1005];
char ans[1005][1005];
signed main()
{
int n,m;
n=read();m=read();
for(int i=0;i<=n+1;i++)
for(int j=0;j<=m+1;j++)
a[i][j]=gc(),ans[i][j]='.';
int i;
for(i=1;i<=n;i++)
{
int L=m+2,R=-1;
if(a[i][0]!='.')
{
for(int j=1;j<=m;j++)
{
if(a[i][j]=='x') continue;
if(a[0][j]==a[i][0] || a[0][j]=='.')
{
L=j;
break;
}
}
}
else L=0;
if(a[i][m+1]!='.')
{
for(int j=m;j>=1;j--)
{
if(a[i][j]=='x') continue;
if(a[0][j]==a[i][m+1] || a[0][j]=='.')
{
R=j;
break;
}
}
}
else R=m+1;
if(L>R || (L==R && a[i][0]!=a[i][m+1]))
{
puts("NO");
return 0;
}
if(a[i][0]!='.') ans[i][L]=a[i][0],a[0][L]='.';
if(a[i][m+1]!='.') ans[i][R]=a[i][m+1],a[0][R]='.';
for(int j=L+1;j<R;j++)
{
if(a[i][j]=='x') continue;
if(a[0][j]!='.') ans[i][j]=a[0][j],a[0][j]='.';
else ans[i][j]=a[n+1][j];
}
bool OK=1;
for(int j=1;j<=m;j++) if(a[0][j]!='.'){OK=0;break;}
if(OK) break;
}
int ti=i;
// cout<<ti<<endl;
for(int j=1;j<=m;j++) if(a[0][j]!='.') {puts("NO");return 0;}
for(int i=n;i>ti;i--)
{
int L=m+2,R=-1;
if(a[i][0]!='.')
{
for(int j=1;j<=m;j++)
{
if(a[i][j]=='x') continue;
if(a[n+1][j]==a[i][0] || a[n+1][j]=='.')
{
L=j;
break;
}
}
}
else L=0;
if(a[i][m+1]!='.')
{
for(int j=m;j>=1;j--)
{
if(a[i][j]=='x') continue;
if(a[n+1][j]==a[i][m+1] || a[n+1][j]=='.')
{
R=j;
break;
}
}
}
else R=m+1;
if(L>R || (L==R && a[i][0]!=a[i][m+1]))
{
puts("NO");
return 0;
}
if(a[i][0]!='.') ans[i][L]=a[i][0],a[n+1][L]='.';
if(a[i][m+1]!='.') ans[i][R]=a[i][m+1],a[n+1][R]='.';
for(int j=L+1;j<R;j++)
{
if(a[i][j]=='x') continue;
if(a[n+1][j]!='.') ans[i][j]=a[n+1][j],a[n+1][j]='.';
else ans[i][j]=a[n+1][j];
}
}
for(int j=1;j<=m;j++)
{
if(a[n+1][j]=='.') continue;
bool g=0;
for(int i=n;i>=1;i--)
{
if(ans[i][j]=='.') continue;
if(ans[i][j]==a[n+1][j])
{
g=1;
break;
}
else break;
}
if(!g) {puts("NO");return 0;}
}
puts("YES");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
cout<<ans[i][j];
cout<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 3644kb
input:
1 2 .... Nx.. ..O.
output:
NO
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
5 5 .U.N.X. U....xX Ox....X M...xxN Vx....S Ix.x..X ..IBHX.
output:
YES UINX. .OBHX M.N.. .VB.S .I.HX
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 1ms
memory: 3684kb
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.. BK...D..U. KKO.ID..T. A.O..D..RJ .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: 3724kb
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..CY.K P.E..VCYSK SP.......A ..EASDCYS.
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 0ms
memory: 3592kb
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.BB HPS.Z ..N.. ....P B...G .F..D ..TK. EP.R. ..SB.
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 1ms
memory: 3748kb
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. NDAF.IJEN.GAOEA.UNUGG.BEWT.X.K.....L..KJ.NAEF.OAE. U.AF..JUNEG.YEAB.NUGGXB.WT.XU.HTANSLM..JKNAEI.OAS. L..F.XJUN.GAYEABUN.GG.B.WT..U.H.ANSLM.NJ.N.E..OAVS Q................................................L F...........................................
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 1ms
memory: 3908kb
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..RNZVDJFC.RB.VE.QXHTG...KZ.SRPPFKYGVT.SQ.ADE.PK..HZ.WW.QX.XJWYGBRBHABF.WHFVU.OLBHM.N .CX.G..ZOWZ.QANZIRG.IDMKC.QA.D.F.R.BZ.GIM.YJR..XK.F..OG.CK..GPQYKKZNQYOQXD.ZB.DBQUZWQF.KO...NHHO..KO .ODHG..ZOWUBQANO.RG.ID..C..A..S..R.BZL....AJR.XXK.FE..GB.K..EPQ.VKZQQ.NQXJ..BYDBQUZ.QF.KODB.TH...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 0ms
memory: 4624kb
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 M..FDL...HREQ..ILNRA..OERZSA.GL.Z.SE.IL.LK.H.ENLNFQS.TWTX.E.K.HOQWA.SE.M.PGTFG.XGY..SUC..OQAX.OGNS.TFSLUIM.UXR..CEC..CXOJNPT.VA..JTFJLHXURYIQI.CVWDB.Z..XFR.T..IPXTD..LHJHSZCW.RMNUGPIHYUQY.YA.IN.CB.UJPM.GYDD.AJW.NZJ...AWAJZAHWAFCB...T.CYZ.HQLNQ.LFA.S.NPBWEDPI.LYLFI.IFXEX...SUO.APVCZP.JXPUSFW.D.WU...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 15ms
memory: 5604kb
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.FDQEAVSGPTHMFIP.TYOQRQOXD.F.XV.Q.M.YO.IYT.QZ.JQISZZMAJCOAWBJBRX..JC.EPP.GGAWGT.B..BLAGPCORMLVD.LHAQR...GFPE.K.CDXLLT.BCL.CGYJB.USPIN..EL..WKJ.G.CFVQ.OLV.LFHYJCMY.FZDR..ODLAYTWIZQO.ZX.WI..DFR..LHLE.A.FG.PLFWFUKAQR.GBJA..TSA..WRGJ...OXDI...Z.L.I.DT.Y.HFKN.WXY.RSY.LSL.RI.G.PU.ZP.V..FLMKT.TWI.ZKHZ...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 0ms
memory: 3640kb
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: 0
Accepted
time: 0ms
memory: 3664kb
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:
YES ..JJPYBD.H..F.I.N.FCQVJKS..Q.PBW..XLW.ZS..ATCTMPPKRK.V.NN.MP..SPN..ODI.HK...R.V..INXOZMGF.KIS.GANJ.WV.YLALHHXO.....MTJ.W.Y.RNLBUENZCUA.I.XJO.Q.N.G.B....I.TVLY.N.CWE.ZEOVANYRZ.WBPQI.LORBYIY..KWJZ.PENB.HPJPTI.GVOMF.RPZ..W.M.IS....QU.Z.X.D.ZU.Y.M.UO.POHV.HW..SZ..HWXW.SZ......R..ZR.L.J.YLL.CE.IEZDX....
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 0ms
memory: 5668kb
input:
1000 1 .N. N.N G.G ... ... .x. U.U ... .x. P.P K.K ..O .x. .x. Y.Y ... .x. ..D .x. ... J.J Q.Q E.E .x. A.. W.. .x. H.H D.D ... ... E.E ..H ..A .x. ... C.C ..E O.O ... ..Z J.J ... ..Y P.P W.W X.X G.G ... ... ... ... L.L F.F B.B .x. K.K R.R U.U F.F .x. ... ... ... B.B ... L.L .x. E.E N.N Z.Z ... Z.Z W...
output:
YES N G . . . U . . P K O . . Y . . D . . J Q E . A W . H D . . E H A . . C E O . Z J . Y P W X G . . . . L F B . K R U F . . . . B . L . E N Z . Z W . . . I V P . . J K D X Y . . . S . X . . J F O S N . D . . E U . . T C D M . . . T . . . . . F . . Y E K . . . . T . . . . G T . A . H R X . . . . U ...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 0ms
memory: 5616kb
input:
1000 2 .HE. .xx. .... H..E ..x. Z..N U.xU ..x. Rx.R A..A D..L J..T ..x. A.xA Ax.A ...V .x.. F..F .x.. U..Q Bx.B F..X E..E ...G B..V ..x. .x.. ..x. E.xE ...I ..x. ...W Tx.T .x.. Tx.T H..H K..K M..I ..xK V..I .x.Y ...V .... A..M B.xB Hx.H A.xA ...K ...X O... J..X S..U X..M F.xF ..x. M..I D.xD Y.xY Hx....
output:
YES .. HE HE .. ZN U. .. .R AA DL JT .. A. .A .V .. FF .. UQ .B FX EE .G BV .. .. .. E. .I .. .W .T .. .T HH KK MI K. VI .Y .V .. AM B. .H A. .K .X O. JX SU XM F. .. MI D. Y. .H XF SX AK .R B. .. .. KE NN Z. .. BI PV ZD .D .G .. RR V. .O EE .. C. .J SP .. GG JI .. .P DH .. QQ .. V. ZL W. QC P. KK .O...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
1 1 .M. M.M .M.
output:
YES M
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
2 2 .FG. F..G D..D .DG.
output:
YES FG D.
result:
ok Correct.
Test #17:
score: 0
Accepted
time: 19ms
memory: 5688kb
input:
1000 1000 .SALZWWWEFVNIEX.ZDPPWJHROFIITXR.CSOKTMFFUGSA.UW.X.QYXWNAC.YCVHOGAHGZQAJWINRU.Z..CCFQKASZXMPWSQGILOT.N.PKGZ.JWPZ.ALPWSOFCMWABPW.ZAFSQQUASJHPIAMITPJEAJLKMGVGDOHFFNYKKXFHUIPFYDPQ.RWKD.PWLTQPZGPMYPQHOAGOHIDQMFGJU.MLXPCUK.ES.KZHPRLBGCTGYHPVYMX.DFAZODQ.QXANEJTISMUGV.LIGKZDSNOC.NDWM.N.JYHJIWCBQ.L...
output:
YES ..LZW..EFV.IEX.ZDPPW.HROF.ITXR..SOKT.FFU.S.WUW.X.QY.WNAC.YCVHOGAHGZQ.JW.NRU.ZZ..CF..A..XMPW.Q...OTSNPPKGZT.WPZVALP.SOFCMWABPWPZAFSQQ.ASJHPI.M.TPJ.A.LKMGVG.OHFFNYK.XFHU.PF.DPQ...KDY.WLT.PZGP...Q.OA.O.ID.MFGJUH.LX...K.ESAKZHPR..GCTGYHPV..XW.FA.O.QHQXANE...S.UG.Q..GKZDS..C.NDW..NB.YHJIW.B.MLIU.N.NI...
result:
ok Correct.
Test #18:
score: 0
Accepted
time: 23ms
memory: 5624kb
input:
1000 1000 ..EYLAGAENPDPZMGY.K.MSRTZBHDENS..YJRW.IWCLBIQQICT.ODBUMXFPO.UDPELUBMQSLZ.EHIVABC.ME.NQQI..QEHTIIFGJQWZSLDNDKGWA.UGMR.CJ.RPAQYJUAIIFQAMRAWECAAFHV.GUGIXROGEYDUX.FUUP.JKSYZITIHMSCKEQQKU.SFAXDPIPSHHYGGYLLEHUHZYRKYBKNAAOAWZHPRKHIQRZJXO.LMJUHDR.AWTBOEEJIHRH.XBUDQHGHKSL.SKW.SZZNIZAF..PK.NVOIMECDI...
output:
YES .......................ZB.DE.S..Y.RWXIW.L.IQ..CT.O.BUMX...SUD.ELUB.QSL..E..VABC.MEON..I.I.EHT..F...W.S.D..KGW..UG.R.C.A.PAQYJUAIIFQA.R....AAFHVUGUG..ROG..DUX...U..J.S....IHMSCKE...U...AXDP...HH.G..L.E.UHZY.KY.K.AAOA..HPR.HI.RZJ..KLMJUH..L.WT..E.JI.RH..BU..HGHK.L.S...SZZ.I..FXI......IME..IKXFG.J....
result:
ok Correct.
Test #19:
score: 0
Accepted
time: 19ms
memory: 5668kb
input:
1000 1000 .YOTYESJGMDJYFO.GICQVC.PBBNUUXFEIX.OJ.DBWOESWK.TEI.DITEQKIKC.QOTZBX..UB..SW.ODDBU.ZDILJKQYEM.CXOWRNAX.RYRPM.VMVYI.PBYXXUDDAFQUMAI..UFRHYOQA.PUWEP.AHEMMHMRCEZRFJQRWKLVXA.HXPHIMHV.SEHGFEJB.WRT.EYCWPI.CTERLDCPFUXKOWGIVNJKKOPUZRZI..NCHBODRTVKZRNHGTOQTYAKSEBA.TEX..EFIVBSBFOAJ.M.PXGTMHN.PRAPFIDD...
output:
YES ..............X.IC......BN......XB.J...W.ESWKY......TEQ.I...QOT..XN.UB.JS.T.D..UX.D.L..QYEM..XOWRNA.CRY..MOV..Y..P...X......U.A..ZUFRH...AXPU.E.XAHE.M....EZR.J.RWK.VX..HX.H.M....E.GF.JBA.RT.E.C.PIWC.E.L.CP..X..W.I.N..KO..ZRZI..N....DR.V.Z.N.GTOQ.Y..SE.AJT.X.PE..VB.BFO.J.M.PX..MH..PRAPF..DH.O.G.T...
result:
ok Correct.
Test #20:
score: 0
Accepted
time: 18ms
memory: 5488kb
input:
1000 1000 .HXXXGGPVDEYBGKDYLMRYKPIY.B..BQBPSH.DHV.RNWZKUYVSVELVLW.IAZZSBAGJSPHY..LFURSTQY.BTDPZ.GQCCNHBHJNUBDRQRGESN.TIGYPZVZ..MAWLKSUBOR.OJ.FEYPDJBAI.WV.EYBPRKNB.V.NY.QESGNGLNTUF.EY.EOIUPSETRWU.AWLP.DCBRZ.IDJIZW.UEJYDHPYOJPH.QJJAR.EOYFQKOSXUK.LNXOHJNINT.NVJFEGZOMSJQT.XHISZWU.Z.GYGELPGGDVTFAGA.TSYDN...
output:
YES .....................P....T.BQ..S.B........KUY......L.U.....B..............T......P.....C..B.J...........U............WL..........F.......I........R.NB.........G.G........T....P.........L..D......DJ.Z........P...P..Q......O.........P.........T.........M....DX......AZC..G.L.GGD....G..........M......
result:
ok Correct.
Test #21:
score: 0
Accepted
time: 11ms
memory: 5604kb
input:
1000 1000 .CCFMBZB.AUU.H.ZXYVAIMTA.D.JJIPERQWJVCTTAKSARUVYRPOPQMNFTNMPUBAZLCD.NXITOLEGFETDCOOBBGTL.U.IDCGBOOWFZ.VAWT.BXDK.YXRPTAVKNVAEMTDFY.UEUJCXSVZTYVJIN.ZOXGSTHSGUJWPTSLSUKFZDICKCPNTF.TTVUZUWAWFIPJ.HSXCJWRLDXZPXSHYLE..VZDEXCIGCFVBJBRNLAZDYXYGBDSRJUKRLVGREJGHMBFFK.SQSFXVDXBOULXPVHXPXKDZADDQA.JJCLE...
output:
YES .................................................................................................W.........................................Y.................................................F........D.............................................................X......................................
result:
ok Correct.
Test #22:
score: -100
Wrong Answer
time: 2ms
memory: 5584kb
input:
1000 1000 .YYJG..U..V.ZKZL.MR.Y.BFP.RK.Y...Y.P...LZ.HB.FECA.O...DDWYTFMKZZ.RZ..AJD....ND.P.B...MPYOAU.DYJX..Y.UEUN..IVDN.C..WXXF...FRP...A..NP.B.O.Z.D..LFC.F..TR.G..M..ULQ..VPC..X.DHPY..UGO.F.P.BM.R..HXJ..STSJMS.Q.AZMF.EF..OXMSV.BAG..ADIR.FD.QDJN.DM...NKI...IYMNE.CP...J...G.KSX..B.J.HLYJC.PMBBJG.F.....
output:
NO
result:
wrong answer Jury has answer but participant has not.