QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102787#5161. Last Guessw4p3r#WA 7ms11752kbC++203.4kb2023-05-03 17:47:312023-05-03 17:47:32

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 17:47:32]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:11752kb
  • [2023-05-03 17:47:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=100010,M=1000010;
const int inf=0x3f3f3f3f;

int head[N],edge[M],ver[M],nxt[M],d[N];
int n,m,maxflow=0,tot=1,s=N-1,t=N-2,ss=N-3,tt=N-4;
void add_edge(int x,int y,int z)
{
	ver[++tot]=y,edge[tot]=z,nxt[tot]=head[x],head[x]=tot;
}
void add(int x,int y,int z)
{
	add_edge(x,y,z),add_edge(y,x,0);
}
void add(int x,int y,int l,int r)
{
	add(ss,y,l),add(x,tt,l),add(x,y,r-l);
}

queue<int> q;
bool bfs(int S,int T)
{
	while(q.size()) q.pop();
	memset(d,0,sizeof(d));
	q.push(S),d[S]=1;
	while(q.size())
	{
		int x=q.front(); q.pop();
		for(int i=head[x];i;i=nxt[i])
		{
			int y=ver[i];
			if(edge[i]&&!d[y]) d[y]=d[x]+1,q.push(y);
		}
	}
	return d[T];
}
int dinic(int x,int flow,int T)
{
	if(x==T||!flow) return flow;
	int res=flow,k;
	for(int i=head[x];i&&res;i=nxt[i])
	{
		int y=ver[i];
		if(edge[i]&&d[y]==d[x]+1)
		{
			k=dinic(y,min(edge[i],res),T);
			if(!k) d[y]=0;
			res-=k,edge[i]-=k,edge[i^1]+=k;
		}
	}
	return flow-res;
}

int g,l;
int minn[33],maxn[33],maxG[33];
int cnt[33],cntG[33];
bool black[33];
bool ban[33][510];
char st[N],col[N];
char ans[N];

int main()
{
	scanf("%d%d",&g,&l);
	for(int i=0;i<26;i++) minn[i]=0,maxn[i]=l;
		memset(ban,false,sizeof(ban));
	for(int i=1;i<g;i++)
	{
		for(int j=0;j<26;j++) cnt[j]=cntG[j]=black[j]=0;
		scanf("%s%s",st+1,col+1);
		// cerr<<st+1<<" "<<col+1<<"\n";
		for(int j=1;j<=l;j++)
		{
			if(col[j]=='G') ans[j]=st[j],cnt[st[j]-'a']++,cntG[st[j]-'a']++;
			if(col[j]=='Y') cnt[st[j]-'a']++,ban[st[j]-'a'][j]=true;
			if(col[j]=='B') black[st[j]-'a']=true,ban[st[j]-'a'][j]=true;
		}
		for(int j=0;j<26;j++)
		{
			maxG[j]=max(maxG[j],cntG[j]);
			minn[j]=max(minn[j],cnt[j]);
			if(black[j]) maxn[j]=min(maxn[j],cnt[j]);
		}
	}

/*
	cerr<<"minn: \n";
	for(int i=0;i<26;i++) cerr<<minn[i]<<" ";
		cerr<<"\n";
	cerr<<"maxn: \n";
	for(int i=0;i<26;i++) cerr<<maxn[i]<<" ";
		cerr<<"\n";
	cerr<<"maxG: \n";
	for(int i=0;i<26;i++) cerr<<maxG[i]<<" ";
		cerr<<"\n";
	cerr<<"ban: \n";
	for(int i=0;i<26;i++,cerr<<"\n")
	{
		cerr<<(char)(i+'a')<<": ";
		for(int j=1;j<=l;j++) cerr<<ban[i][j];
	}
	cerr<<"\n";
//*/

	for(int i=0;i<26;i++) add(s,i,minn[i]-maxG[i],maxn[i]-maxG[i]);

	int totG=0;
	for(int i=1;i<=l;i++)
	{
		if(ans[i])
		{
			totG++;
			continue;
		}
		add(26+i,t,1,1);
		for(int ch=0;ch<26;ch++)
			if(!ban[ch][i]) add(ch,26+i,0,1);
	}

/*
	for(int x=0;x<26;x++)
	{
		cerr<<(char)(x+'a')<<": \n";
		for(int i=head[x];i;i=nxt[i])
		{
			int y=ver[i];
			if(26+1<=y&&y<=26+l) cerr<<(char)(x+'a')<<" "<<y-26<<"\n";
		}
	}
//*/
/*
	cerr<<"ss = "<<ss<<", tt = "<<tt<<"\n";
	for(int x=0;x<N;x++)
	{
		for(int i=head[x];i;i=nxt[i])
		{
			int y=ver[i],z=edge[i];
			if(z) cerr<<x<<" "<<y<<" "<<z<<"\n";
		}
	}
//*/

	add(t,s,0,inf);
	int flow=0;
	while(bfs(ss,tt)) while(flow=dinic(ss,inf,tt)) maxflow+=flow;

	for(int i=head[ss];i;i=nxt[i]) edge[i]=edge[i^1]=0;
	for(int i=head[tt];i;i=nxt[i]) edge[i]=edge[i^1]=0;
	for(int i=head[t];i;i=nxt[i]) if(ver[i]==s) edge[i]=edge[i^1]=0;
	// edge[tot]=edge[tot-1]=0;
	while(bfs(s,t)) while(flow=dinic(s,inf,t)) maxflow+=flow;
	cerr<<maxflow<<" "<<totG<<" "<<l<<"\n";
	for(int i=0;i<26;i++)
	{
		for(int j=head[i];j;j=nxt[j])
		{
			int y=ver[j];
			if(26+1<=y&&y<=26+l&&!edge[j]) ans[y-26]=i+'a';
		}
	}
	for(int i=1;i<=l;i++) putchar(ans[i]);
		putchar('\n');
	// assert(maxflow+totG==l);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 9588kb

input:

4 5
reply YYGBB
refer BBBGG
puppy YYGBB

output:

upper

result:

ok 

Test #2:

score: 0
Accepted
time: 3ms
memory: 8032kb

input:

2 12
aabbccddeeff GGGYGBYYYBBB

output:

aabzczzzbdde

result:

ok 

Test #3:

score: 0
Accepted
time: 7ms
memory: 9708kb

input:

25 500
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjq...

output:

zzzzzzzzzzzzzzzzz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qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqq...

output:

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...

result:

ok 

Test #6:

score: 0
Accepted
time: 6ms
memory: 9612kb

input:

22 500
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccoccccccccccccccccccccccccccccccccccccccccccccccccfccccccccccccccccccccccccccccccccc...

output:

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...

result:

ok 

Test #7:

score: 0
Accepted
time: 1ms
memory: 8068kb

input:

30 20
azzzzzzzzzzzzzzzzzzz YBBBBBBBBBBBBBBBBBBB
zazzzzzzzzzzzzzzzzzz BGBBBBBBBBBBBBBBBBBB
zzazzzzzzzzzzzzzzzzz BBYBBBBBBBBBBBBBBBBB
zzzazzzzzzzzzzzzzzzz BBBYBBBBBBBBBBBBBBBB
zzzzazzzzzzzzzzzzzzz BBBBGBBBBBBBBBBBBBBB
zzzzzazzzzzzzzzzzzzz BBBBBYBBBBBBBBBBBBBB
zzzzzzazzzzzzzzzzzzz BBBBBBYBBBBBBBBBBBBB
...

output:

vajlabmpqyavasaaravu

result:

ok 

Test #8:

score: 0
Accepted
time: 0ms
memory: 8032kb

input:

31 20
azzzzzzzzzzzzzzzzzzz GBBBBBBBBBBBBBBBBBBB
zazzzzzzzzzzzzzzzzzz BYBBBBBBBBBBBBBBBBBB
zzazzzzzzzzzzzzzzzzz BBYBBBBBBBBBBBBBBBBB
zzzazzzzzzzzzzzzzzzz BBBYBBBBBBBBBBBBBBBB
zzzzazzzzzzzzzzzzzzz BBBBYBBBBBBBBBBBBBBB
zzzzzazzzzzzzzzzzzzz BBBBBYBBBBBBBBBBBBBB
zzzzzzazzzzzzzzzzzzz BBBBBBGBBBBBBBBBBBBB
...

output:

ayyduiasiaafbuqvayya

result:

ok 

Test #9:

score: 0
Accepted
time: 1ms
memory: 7980kb

input:

38 20
azzzzzzzzzzzzzzzzzzz YBBBBBBBBBBBBBBBBBBB
zazzzzzzzzzzzzzzzzzz BGBBBBBBBBBBBBBBBBBB
zzazzzzzzzzzzzzzzzzz BBYBBBBBBBBBBBBBBBBB
zzzazzzzzzzzzzzzzzzz BBBGBBBBBBBBBBBBBBBB
zzzzazzzzzzzzzzzzzzz BBBBGBBBBBBBBBBBBBBB
zzzzzazzzzzzzzzzzzzz BBBBBYBBBBBBBBBBBBBB
zzzzzzazzzzzzzzzzzzz BBBBBBYBBBBBBBBBBBBB
...

output:

sawaakoaaaeaoaahaaal

result:

ok 

Test #10:

score: 0
Accepted
time: 6ms
memory: 8220kb

input:

25 500
eppppsppppppappppapppaswppspwppeupppwpwppppwppspppppppapppppspppappwpppppspspuppppppppppupwppeppppppppuppppusppspppppppwppppppppspeppppppppppepspppeppuppppwpppppppppppppwpppppppwppupppppspppppppppppppupeppppppppsppppeppaeppppppppppppppppppappppppppppppppppsppwppuappppepupuapppeppppppapppppppp...

output:

vayjogcjsnarhzfrshqbxhgirsgmitjvlabdikinenuizmgwwuqtzohxzeudgtmnhsaiacratgwgjljtkyetowdwlaibdvksccbsonlmrdjlgbngconrstmidytrdknwgjvyxzueqskrnvqgzmtvaelfxubiaqctbexjeftotinkqfsusinolqbsxjgcrqwkerywwmyylevubemsnzagqjtuvcuhvrbcnfcxznfymkquskbhffkcxrezezkemfyfgfzirxlhanfbvrldlhfcavqzzcbyhycwtknftnxhomqg...

result:

ok 

Test #11:

score: 0
Accepted
time: 5ms
memory: 8152kb

input:

25 500
smxeetdiacxotgkpibsieraggqfjdbjxykzpiinrjxkmcczngkgpidtnacrzonzmrjsyfaiptigawddifgqxiiqibyymxvzncvifqsyfxmeodqwvwgqegpizkzfvsyywomkaviwjcasacijfbpjibvsroitinpfddjzcdkmxeisynrzipizmoyveveqwsfaqixobgrkstwtdtcfbwrvyvrgwdcmjozmitwcfitpzqdnikqbcpzyerwwigzdiczfmagmvacqxwbbiiiqrgxwvprvicjdsajinpmrrn...

output:

lxrggumnthrcukqbzoljgstkkayvmovrpqfbjjwsvrqxhhfwkqkbnmuwthsfcwfxsvlpytjbuzktdmmnykarnnanoppxrefwhejyalpyrxgcmadedkagkbnfqfyelppdcxqtendvhtlthnvyobvzoelscnuzwbymmvfhmqxrgnlpwsfjbjfxcpegegadlytajrcoksqludumuhyodsepeskdmhxvcfxjudhyzubfamwnqaohbfpgsddzkfmjhfyxtkxethardoojjzaskrdebsenhvmltvzwbxsswengqqwz...

result:

ok 

Test #12:

score: 0
Accepted
time: 5ms
memory: 8236kb

input:

25 500
zzzzzzzzzzezzzzzyzzzyfzzzzzyzfzzzzzuzzzzzzzzyezezzzyzzzzzzzzzzzzzzzuzzzzzzzzfzzzzzzzyzzezfzzzzzzzzzzzzzzzzzzzzzzzfzzzzzzzzzzzzzzuzzzzzzzzzzzzzzzzzzzzuzzzzzzzzzzzyzzzzuzzzzzzzyyzzzzzzzzzzzzzzzzzfzzzzzzzzzzyzzzzyzzzzzzeezzzzzzzzzzyzzzzzzzyzezzzfefzuzzzzzzzzzzzzzuzfzzzzzzezzzfzzzzzzzzzzyuezzfzzz...

output:

qjtwjfaynbvccrdxmkyemidubqxmbidthnhseryxlaeymvbvdqgmjplbtulcjwhffjcsftewuqbxixoaeklqmfcvjiyeuthdcnfrqlwcoynrwjtxyinarlkxyfwkcjwxsqbcldqgnhuohjjbalwyasdpgxqdrbenwmyonrsplnurofmmjjfkxwoqabotkkoatikpndnkqcqxmlpggmanbphuvvttrwehopqgmkreelbdmyvrhgivicskkpqgklfpyytlsxixrlogyvqanirnpjbxexfdmsvgfiepdgrsdfgd...

result:

ok 

Test #13:

score: 0
Accepted
time: 4ms
memory: 11752kb

input:

26 500
ffafffffafffffffffffffaaffaffffffffffffffffffffffffafffaffafffffffafffffffffffffffffffffffafaffffffffffafffffafffffffffafaffffffffffffffffffffaffffffffffffffffaffaffffffffffffffaffffffffffafffffafffaaffffffafafffafffffffffffffffaaffffffafffffffffffafffffffffffafffffafffffffaffffffffffafafffff...

output:

jlfbhgclfgttbbjhnbeionffhnfhcvbntvnxbonioebgbbwobonfobtfnofjtwbtbpfnjtbbgwphwpgxgjcbvtnothftfwbhhpbcpjifdhjwwfhgdijtwdifhfponbphownknommrhrkojflkjklplbekwedltcfoefidwgchwiojoenkfnjlitodlohqpluwhqcusfgumbuhkqifumrqrrcdskehgmktsttqfwnsuwcqujjetdpkpbtqcweuhrupxsrfrtxhkqryirsusgtjplplipmrftgcutxivpqggci...

result:

ok 

Test #14:

score: 0
Accepted
time: 3ms
memory: 8020kb

input:

26 500
eeeeeeeeeeleleeeleeleelleelellelleeeleeeeeeeeeeeeeeeeeeeleeeeeeeleeleeeeelelleeelleeeleeeeeeeeeeeeeeeeeeleeeeeeeleeeeeellleeeeeeleleeeeeeleeeleeeeeeeeeeeeeeleeeeleeeeeeeeeeeeeellleleeeeeeeeeeelleleeeeeleleeleleeeeeeeeeeleeleeelelelleeeeeeleeeleeeeeeeeeeelleeeeeeeeeeeleeeeeleeeeleleeeeeeeellee...

output:

ajmmzkdgsgnaegianrtejueeudecexaxegkcxrtppdcrdofsscijdakieapbbgacxkfxbbbireaexckchxcrbebmsmamkmffdrafprsghjdkbckgxrwpbkvxehbjgyyikakjgvivihdwrebtatpkrrdrftpjeuboaejkirryadabpybghxxihkvagkpvikjpxxuusgwbdhynwdxshjivadawgayxygnbtgkwhrxnfcrootkcbrxbyugoonsimbhnormuvpvvptbuzwannxtbstntxooiwmwswhxsvskhntns...

result:

ok 

Test #15:

score: 0
Accepted
time: 2ms
memory: 8092kb

input:

26 500
dddddddddddkddddddddddddddddddddkdddddkddddddddkddddkddddddkddddddddkdddkddddddddddddddddddddddddddddddddddkdddddddddkdkddddddddddddddddddddddddddkdddddddddddkdkkkddddddddddddddddddddkddkddddddddddddddddddddddddddddddddddddddddddddddkdddddddddddddddddkdkdddkddkdddkddddddkdddddddddddddkddddddd...

output:

enecqarucfidncbebhgifbebcemelvfbdrnfcidebbjbbqqdrhiadezbchndhjnuhcubshtnehbeiultjhmejfnjlqeprjmtmtfjjthicttdttcanxghadlsoctemjtaqueenxucefhljotjopqrrqggoqtiyuqiqsduxwimewewtpnihipfppespldixnrxpfxffffmrfyujhpjiuxfwalhwftnrmrffttpjmljusytxuayjsgmugxvuxtdyshamdvsszamdjxriwmqumghwuspzuamasazgszpsgswsthu...

result:

ok 

Test #16:

score: 0
Accepted
time: 1ms
memory: 8052kb

input:

2 1
s B

output:

z

result:

ok 

Test #17:

score: 0
Accepted
time: 1ms
memory: 7976kb

input:

5 3
idn BBY
mvh BBB
cva BBG
you BBB

output:

zna

result:

ok 

Test #18:

score: 0
Accepted
time: 0ms
memory: 8024kb

input:

3 2
jt BB
bg BB

output:

zz

result:

ok 

Test #19:

score: 0
Accepted
time: 1ms
memory: 9844kb

input:

4 8
jzhqnmbc BBBBBBBY
quubxmwq BBBBYBBB
zkmtxamf BBBYYBBB

output:

yyyyyctx

result:

ok 

Test #20:

score: 0
Accepted
time: 3ms
memory: 7976kb

input:

83 28
yyjekmbfltupxglbgnniupgrbbhh YYYYYYBYBBYYYYBBYYBBBBBYGBYY
gvgwlfkbriylbdfmajjupyijghxk GYYYBYYYYBYBBYBYYYBYYYBGBYYB
jjqnbpooxrfsqntbitwbgrplljzp YBYYYYBBYYYYBBBBBBYBYBBBBGBB
lqdozqobdhvzmtusczvxthcfvymz BYGBBBBYBYYBYBYYBBBYBYBYBYBB
tkhuvtpuhnmzphnqhpfzfsokewoh BYYYYBYBYYGBBBBYBBGBBYBBYYBB
gjer...

output:

gndxhueyqpmeryvhxafwwgkjbjss

result:

ok 

Test #21:

score: -100
Wrong Answer
time: 1ms
memory: 8068kb

input:

13 78
imwrldcrlcooqlzmcczciijjughombdengtcurojkwqyuoqltmduvwebvyysshwjythllxhrwmcepz YYYYYYYYYYYYYYYYYBYBYYYYYYYYYYBYBYYBBYBYGYYYBBYBGBBBYYYBBYYYYYBGBYYBBYYYBBBYYY
pkcwlbnthqplkuohoonvnqbouaakqdpwsyoscpqagkfhfpualsnonjnkkdtudoyvknpjgyhaqoxwak YYYYYYBYYYYYYYYYYYBYBYBBBBBBYYYYYYBYYBYBYBYYYBBBYBBBBYBBB...

output:

ohhgjjrjriigjhijjlkzllimpmphtozoupqzqmxzkrrzoyretietscsdqtetqtzjtvwwzwzzyczxyy

result:

FAIL Wrong answer: does not fit word 0