QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241702#6398. Puzzle: Tapaucup-team902#WA 0ms3776kbC++142.7kb2023-11-06 16:08:052023-11-06 16:08:05

Judging History

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

  • [2023-11-06 16:08:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2023-11-06 16:08:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
namespace IO{
#define gc getchar
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readll;
using IO::readchar;
using IO::readstring;
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}

cs int N=105,M=55*55;
char s[N][N];
int a[M];
int n,m,cnt;
int id[N][N];
pii p[M];
vector<int> e[M];
int vis[M],mat[M];
void add(int u,int v){
	if(a[u]==1||a[v]==1)return;
	if(u&1)e[u].pb(v);
	else e[v].pb(u);
}
bool dfs(int u){
	if(vis[u])return false;
	vis[u]=1;
	for(int v:e[u]){
		if(!mat[v]||dfs(mat[v])){
			mat[v]=u;return true;
		}
	}
	return false;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=2*n-1;i++){
		readstring(s[i]);
		
		if(i&1){
			for(int j=2;j<=2*m-1;j+=2)s[i][j]='#';
			for(int j=1;j<=2*m-1;j+=2){
				//a[(i+1)/2][(j+1)/2]=s[i]-'0';
				id[(i+1)/2][(j+1)/2]=++cnt;
				a[cnt]=s[i][j]-'0';
				if(a[cnt]<=3)a[cnt]-=2;
				else if(a[cnt]<=5)a[cnt]-=4;
				else if(a[cnt]<=8)a[cnt]-=7;
				p[cnt]=pii(i,j);
			}
		}
		else{
			for(int j=1;j<=2*m-1;j++)s[i][j]='#';
		}
	}
	// puts("");
	// for(int i=1;i<=2*n-1;i++){
	// 	cout<<(s[i]+1)<<'\n';
	// }puts("");
	for(int i=1;i<m;i++){
		add(id[1][i],id[1][i+1]);
		add(id[n][i],id[n][i+1]);
	}
	for(int i=1;i<n;i++){
		add(id[i][1],id[i+1][1]);
		add(id[i][m],id[i+1][m]);
	}
	for(int i=2;i<n;i++)
	for(int j=2;j+1<m;j++){
		add(id[i][j],id[i][j+1]);
	}
	for(int i=2;i+1<n;i++)
	for(int j=2;j<m;j++){
		add(id[i][j],id[i+1][j]);
	}
	for(int i=1;i<=cnt;i++)if(a[i]==0&&(i&1)){
		memset(vis,0,sizeof(vis));
		if(!(dfs(i))){
			puts("NO");exit(0);
		}
	}
	for(int i=1;i<=cnt;i++)if(a[i]==0&&(i%2==0)){
		if(!mat[i]){
			puts("NO");exit(0);
		}
		int px=p[i].fi+p[mat[i]].fi;
		int py=p[i].se+p[mat[i]].se;
		s[px/2][py/2]='.';
	}
	puts("YES");
	for(int i=1;i<=2*n-1;i++){
		cout<<(s[i]+1)<<'\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3660kb

input:

3 3
2.4.3
.....
5.8.5
.....
3.5.3

output:

YES
2.4#3
#####
5#8#5
#####
3#5#3

result:

ok Correct.

Test #2:

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

input:

3 3
3.4.3
.....
5.7.5
.....
3.5.3

output:

NO

result:

ok Correct.

Test #3:

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

input:

2 2
2.2
...
2.2

output:

YES
2.2
###
2.2

result:

ok Correct.

Test #4:

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

input:

2 50
2.4.4.4.4.5.5.5.5.5.5.5.5.4.5.5.4.4.5.5.5.5.4.5.5.5.5.5.4.4.5.4.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.4.5.3
...................................................................................................
2.5.5.4.4.5.5.5.4.4.5.5.5.4.5.5.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.5.4.4.5.5.5.5.4...

output:

NO

result:

ok Correct.

Test #5:

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

input:

2 50
2.4.4.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.4.4.5.5.4.4.5.5.5.4.5.4.4.4.5.4.4.5.4.4.5.5.5.5.4.4.5.5.5.5.5.2
...................................................................................................
3.5.4.5.5.5.5.5.5.5.5.5.5.5.4.5.5.5.5.4.5.5.5.5.4.4.5.4.5.4.5.5.5.5.5.4.4.5.5.5.4.4.5.5.5.5.5.4...

output:

NO

result:

ok Correct.

Test #6:

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

input:

50 2
3.2
...
5.4
...
5.5
...
4.4
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.4
...
5.4
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.4
...
5.4
...
5.4
...
5.4
...
4.4
...
5.5
...
5.5
...
4.4
...
5.4
...
5.4
...
5.5
...
4.5
...
4.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
...
5.5
......

output:

NO

result:

ok Correct.

Test #7:

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

input:

50 2
3.3
...
5.4
...
5.4
...
5.4
...
5.4
...
5.5
...
4.4
...
4.4
...
5.5
...
4.4
...
5.5
...
5.5
...
5.5
...
5.5
...
4.5
...
5.5
...
5.5
...
5.4
...
5.4
...
5.5
...
5.4
...
5.5
...
5.4
...
5.4
...
5.5
...
5.5
...
4.5
...
4.5
...
4.5
...
4.5
...
5.5
...
5.4
...
5.4
...
5.5
...
5.5
...
4.4
...
4.4
......

output:

NO

result:

ok Correct.

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3700kb

input:

3 50
3.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.4.4.5.5.5.5.5.5.5.5.4.4.5.5.4.4.5.4.4.5.3
...................................................................................................
4.8.8.8.8.8.8.8.8.8.8.8.8.8.8.7.7.7.7.7.7.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.7.7.8...

output:

NO

result:

wrong answer Jury has answer but participant has not.