QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102953#5161. Last GuesswangxuyeWA 6ms9964kbC++202.4kb2023-05-03 20:34:572023-05-03 20:34:57

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 20:34:57]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:9964kb
  • [2023-05-03 20:34:57]
  • 提交

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);
		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]=cnt[j];
		}
	}

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

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

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

	for(int i=1;i<=tot;i++) if(i&1) edge[i]=0;
	for(int i=0;i<26;i++) add(ss,i,maxn[i]-minn[i]);
	while(bfs(ss,t)) while(flow=dinic(ss,inf,t)) maxflow+=flow;

	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');
	return 0;
}

詳細信息

Test #1:

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

input:

4 5
reply YYGBB
refer BBBGG
puppy YYGBB

output:

upper

result:

ok 

Test #2:

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

input:

2 12
aabbccddeeff GGGYGBYYYBBB

output:

aabzczzzbdde

result:

ok 

Test #3:

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

input:

25 500
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq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qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqq...

output:

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...

result:

ok 

Test #6:

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

input:

22 500
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccoccccccccccccccccccccccccccccccccccccccccccccccccfccccccccccccccccccccccccccccccccc...

output:

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

result:

ok 

Test #7:

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

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: 2ms
memory: 8052kb

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: 3ms
memory: 8012kb

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: 5ms
memory: 8088kb

input:

25 500
eppppsppppppappppapppaswppspwppeupppwpwppppwppspppppppapppppspppappwpppppspspuppppppppppupwppeppppppppuppppusppspppppppwppppppppspeppppppppppepspppeppuppppwpppppppppppppwpppppppwppupppppspppppppppppppupeppppppppsppppeppaeppppppppppppppppppappppppppppppppppsppwppuappppepupuapppeppppppapppppppp...

output:

vayjogcjsnarhzfrshqbxhgirsgmitjvlabdikinenuizmgwwuqtzohxzeudgtmnhsaiacratgwgjljtkyetowdwlaibdvksccbsonlmrdjlgbngconrstmidytrdknwgjvyxzueqskrnvqgzmtvaelfxubiaqctbexjeftotinkqfsusinolqbsxjgcrqwkerywwmyylevubemsnzagqjtuvcuhvrbcnfcxznfymkquskbhffkcxrezezkemfyfgfzirxlhanfbvrldlhfcavqzzcbyhycwtknftnxhomqg...

result:

ok 

Test #11:

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

input:

25 500
smxeetdiacxotgkpibsieraggqfjdbjxykzpiinrjxkmcczngkgpidtnacrzonzmrjsyfaiptigawddifgqxiiqibyymxvzncvifqsyfxmeodqwvwgqegpizkzfvsyywomkaviwjcasacijfbpjibvsroitinpfddjzcdkmxeisynrzipizmoyveveqwsfaqixobgrkstwtdtcfbwrvyvrgwdcmjozmitwcfitpzqdnikqbcpzyerwwigzdiczfmagmvacqxwbbiiiqrgxwvprvicjdsajinpmrrn...

output:

lxrggumnthrcukqbzoljgstkkayvmovrpqfbjjwsvrqxhhfwkqkbnmuwthsfcwfxsvlpytjbuzktdmmnykarnnanoppxrefwhejyalpyrxgcmadedkagkbnfqfyelppdcxqtendvhtlthnvyobvzoelscnuzwbymmvfhmqxrgnlpwsfjbjfxcpegegadlytajrcoksqludumuhyodsepeskdmhxvcfxjudhyzubfamwnqaohbfpgsddzkfmjhfyxtkxethardoojjzaskrdebsenhvmltvzwbxsswengqqwz...

result:

ok 

Test #12:

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

input:

25 500
zzzzzzzzzzezzzzzyzzzyfzzzzzyzfzzzzzuzzzzzzzzyezezzzyzzzzzzzzzzzzzzzuzzzzzzzzfzzzzzzzyzzezfzzzzzzzzzzzzzzzzzzzzzzzfzzzzzzzzzzzzzzuzzzzzzzzzzzzzzzzzzzzuzzzzzzzzzzzyzzzzuzzzzzzzyyzzzzzzzzzzzzzzzzzfzzzzzzzzzzyzzzzyzzzzzzeezzzzzzzzzzyzzzzzzzyzezzzfefzuzzzzzzzzzzzzzuzfzzzzzzezzzfzzzzzzzzzzyuezzfzzz...

output:

qjtwjfaynbvccrdxmkyemidubqxmbidthnhseryxlaeymvbvdqgmjplbtulcjwhffjcsftewuqbxixoaeklqmfcvjiyeuthdcnfrqlwcoynrwjtxyinarlkxyfwkcjwxsqbcldqgnhuohjjbalwyasdpgxqdrbenwmyonrsplnurofmmjjfkxwoqabotkkoatikpndnkqcqxmlpggmanbphuvvttrwehopqgmkreelbdmyvrhgivicskkpqgklfpyytlsxixrlogyvqanirnpjbxexfdmsvgfiepdgrsdfgd...

result:

ok 

Test #13:

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

input:

26 500
ffafffffafffffffffffffaaffaffffffffffffffffffffffffafffaffafffffffafffffffffffffffffffffffafaffffffffffafffffafffffffffafaffffffffffffffffffffaffffffffffffffffaffaffffffffffffffaffffffffffafffffafffaaffffffafafffafffffffffffffffaaffffffafffffffffffafffffffffffafffffafffffffaffffffffffafafffff...

output:

jlfbhgclfgttbbjhnbeionffhnfhcvbntvnxbonioebgbbwobonfobtfnofjtwbtbpfnjtbbgwphwpgxgjcbvtnothftfwbhhpbcpjifdhjwwfhgdijtwdifhfponbphownknommrhrkojflkjklplbekwedltcfoefidwgchwiojoenkfnjlitodlohqpluwhqcusfgumbuhkqifumrqrrcdskehgmktsttqfwnsuwcqujjetdpkpbtqcweuhrupxsrfrtxhkqryirsusgtjplplipmrftgcutxivpqggci...

result:

ok 

Test #14:

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

input:

26 500
eeeeeeeeeeleleeeleeleelleelellelleeeleeeeeeeeeeeeeeeeeeeleeeeeeeleeleeeeelelleeelleeeleeeeeeeeeeeeeeeeeeleeeeeeeleeeeeellleeeeeeleleeeeeeleeeleeeeeeeeeeeeeeleeeeleeeeeeeeeeeeeellleleeeeeeeeeeelleleeeeeleleeleleeeeeeeeeeleeleeelelelleeeeeeleeeleeeeeeeeeeelleeeeeeeeeeeleeeeeleeeeleleeeeeeeellee...

output:

ajmmzkdgsgnaegianrtejueeudecexaxegkcxrtppdcrdofsscijdakieapbbgacxkfxbbbireaexckchxcrbebmsmamkmffdrafprsghjdkbckgxrwpbkvxehbjgyyikakjgvivihdwrebtatpkrrdrftpjeuboaejkirryadabpybghxxihkvagkpvikjpxxuusgwbdhynwdxshjivadawgayxygnbtgkwhrxnfcrootkcbrxbyugoonsimbhnormuvpvvptbuzwannxtbstntxooiwmwswhxsvskhntns...

result:

ok 

Test #15:

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

input:

26 500
dddddddddddkddddddddddddddddddddkdddddkddddddddkddddkddddddkddddddddkdddkddddddddddddddddddddddddddddddddddkdddddddddkdkddddddddddddddddddddddddddkdddddddddddkdkkkddddddddddddddddddddkddkddddddddddddddddddddddddddddddddddddddddddddddkdddddddddddddddddkdkdddkddkdddkddddddkdddddddddddddkddddddd...

output:

enecqarucfidncbebhgifbebcemelvfbdrnfcidebbjbbqqdrhiadezbchndhjnuhcubshtnehbeiultjhmejfnjlqeprjmtmtfjjthicttdttcanxghadlsoctemjtaqueenxucefhljotjopqrrqggoqtiyuqiqsduxwimewewtpnihipfppespldixnrxpfxffffmrfyujhpjiuxfwalhwftnrmrffttpjmljusytxuayjsgmugxvuxtdyshamdvsszamdjxriwmqumghwuspzuamasazgszpsgswsthu...

result:

ok 

Test #16:

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

input:

2 1
s B

output:

z

result:

ok 

Test #17:

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

input:

5 3
idn BBY
mvh BBB
cva BBG
you BBB

output:

zna

result:

ok 

Test #18:

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

input:

3 2
jt BB
bg BB

output:

zz

result:

ok 

Test #19:

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

input:

4 8
jzhqnmbc BBBBBBBY
quubxmwq BBBBYBBB
zkmtxamf BBBYYBBB

output:

yyyyyctx

result:

ok 

Test #20:

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

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: 2ms
memory: 9628kb

input:

13 78
imwrldcrlcooqlzmcczciijjughombdengtcurojkwqyuoqltmduvwebvyysshwjythllxhrwmcepz YYYYYYYYYYYYYYYYYBYBYYYYYYYYYYBYBYYBBYBYGYYYBBYBGBBBYYYBBYYYYYBGBYYBBYYYBBBYYY
pkcwlbnthqplkuohoonvnqbouaakqdpwsyoscpqagkfhfpualsnonjnkkdtudoyvknpjgyhaqoxwak YYYYYYBYYYYYYYYYYYBYBYBBBBBBYYYYYYBYYBYBYBYYYBBBYBBBBYBBB...

output:

ohhgjjrjriigjhijjlkzllimpmphtozoupqzqmxzkrrzoyretietscsdqtetqtzjtvwwzwzzyczxyy

result:

FAIL Wrong answer: does not fit word 0