QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#231978#7637. Exactly Three Neighborsucup-team918AC ✓0ms3692kbC++142.9kb2023-10-29 18:34:482023-10-29 18:34:48

Judging History

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

  • [2023-10-29 18:34:48]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3692kb
  • [2023-10-29 18:34:48]
  • 提交

answer

/* Code by pp_orange */
#include<bits/stdc++.h>
#define m_p(a,b) make_pair(a,b)
#define pb push_back
#define ll long long
#define ull unsigned long long
#define lld long double
#define inf 0x7FFFFFFF
#define inff 9223372036854775807
#define rep(i,l,r) for(int i=l;i<r;++i)
#define repp(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r-1;i>=l;--i)
#define pper(i,r,l) for(int i=r;i>=l;--i)
#define pii pair<int,int>
#define fi first
#define se second
#define p_q priority_queue
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ls(x) ((x)<<1)
#define rs(x) ((x)<<1|1)
#define lb(x) ((x)&-(x))
const int mod = 998244353;
//#define int ll
using namespace std;
inline int rd(){
	int x(0),f(1);char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while (isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*f;
}
inline void out(int X){
	if(X<0) {X=~(X-1); putchar('-');}
	if(X>9) out(X/10);
	putchar(X%10+'0');
}
ll pw(ll x,int d){
	ll t = 1;
	for(;d;d>>=1,x=x*x%mod)if(d&1)t = t*x%mod;
	return t;
}
#define MAX 200005
signed main(){
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	int p = rd();
	int q = rd();
	if(5*p>4*q){
		cout<<-1<<' '<<-1<<endl;
		return 0;
	}
	if(p==0){
		cout<<"1 1\n.\n";
		return 0;
	}
	if(p<=2){
		if(p==1)p*=2,q*=2;
		cout<<1<<' '<<q<<endl;
		rep(i,0,p)cout<<"#";
		rep(i,0,q-p)cout<<".";
		cout<<endl;
		return 0;
	}
	if(p==3&&q==4){
		cout<<"4 4\n#.##\n#.##\n###.\n###.\n";
		return 0;
	}
	if(p==3){
		bool ans[100];
		memset(ans,0,sizeof(ans));
		ans[1] = ans[2] = ans[4] = ans[5] = ans[7] = ans[8] = 1;
		q *= 2;
		cout<<1<<' '<<q<<endl;
		rep(i,0,q){
			if(ans[i])cout<<"#";
			else cout<<".";
		}cout<<endl;
		return 0;
	}
	if(p==4&&q==5){
		cout<<"5\n5\n.####\n##.##\n####.\n#.###\n###.#\n";
		return 0;
	}
	if(p==4){
		bool ans[100];
		memset(ans,0,sizeof(ans));
		ans[1] = ans[2] = ans[4] = ans[5] = 1;
		cout<<1<<' '<<q<<endl;
		rep(i,0,q){
			if(ans[i])cout<<"#";
			else cout<<".";
		}cout<<endl;
		return 0;
	}
	if(p==5&&q==7){
		cout<<"4 14\n#.###.###.####\n#.###.###.####\n###.###.###...\n###.###.###...\n";
	//	cout<<-1<<endl;
	//	assert(false);
		return 0;
	}
	if(p==5){
		bool ans[100];
		memset(ans,0,sizeof(ans));
		ans[1] = ans[2] = ans[4] = ans[5] = ans[7] = ans[8] = ans[10] = ans[11] = ans[13] = ans[14] = 1;
		q *= 2;
		cout<<1<<' '<<q<<endl;
		rep(i,0,q){
			if(ans[i])cout<<"#";
			else cout<<".";
		}cout<<endl;
		return 0;
	}
	if(p==7&&q==9){
		bool ans[18][6];
		memset(ans,0,sizeof(ans));
		rep(i,0,6){
			ans[i*3][(4+i)%6] = 1;
			ans[i*3+2][(3+i)%6] = 1;
			ans[i*3+1][(0+i)%6] = ans[i*3+1][(1+i)%6] = 1;
		}
		cout<<18<<' '<<6<<endl;
		rep(i,0,18){
			rep(j,0,6){
				cout<<"#."[ans[i][j]];
			}cout<<endl;
		}
		return 0;
	}
	if(p==7&&q==10){
		cout<<"4 5\n##.##\n##.##\n.###.\n.###.\n";
		return 0;
	}
	while(1);
	return 0;
}

详细

Test #1:

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

input:

2 3

output:

1 3
##.

result:

ok good solution

Test #2:

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

input:

1 1

output:

-1 -1

result:

ok no solution

Test #3:

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

input:

3 4

output:

4 4
#.##
#.##
###.
###.

result:

ok good solution

Test #4:

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

input:

3 5

output:

1 10
.##.##.##.

result:

ok good solution

Test #5:

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

input:

4 5

output:

5
5
.####
##.##
####.
#.###
###.#

result:

ok good solution

Test #6:

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

input:

7 10

output:

4 5
##.##
##.##
.###.
.###.

result:

ok good solution

Test #7:

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

input:

5 7

output:

4 14
#.###.###.####
#.###.###.####
###.###.###...
###.###.###...

result:

ok good solution

Test #8:

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

input:

7 9

output:

18 6
####.#
..####
###.##
#####.
#..###
####.#
.#####
##..##
#####.
#.####
###..#
.#####
##.###
####..
#.####
###.##
.####.
##.###

result:

ok good solution

Test #9:

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

input:

0 1

output:

1 1
.

result:

ok good solution

Test #10:

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

input:

1 2

output:

1 4
##..

result:

ok good solution

Test #11:

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

input:

1 3

output:

1 6
##....

result:

ok good solution

Test #12:

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

input:

1 4

output:

1 8
##......

result:

ok good solution

Test #13:

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

input:

1 5

output:

1 10
##........

result:

ok good solution

Test #14:

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

input:

1 6

output:

1 12
##..........

result:

ok good solution

Test #15:

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

input:

1 7

output:

1 14
##............

result:

ok good solution

Test #16:

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

input:

1 8

output:

1 16
##..............

result:

ok good solution

Test #17:

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

input:

1 9

output:

1 18
##................

result:

ok good solution

Test #18:

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

input:

1 10

output:

1 20
##..................

result:

ok good solution

Test #19:

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

input:

2 5

output:

1 5
##...

result:

ok good solution

Test #20:

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

input:

2 7

output:

1 7
##.....

result:

ok good solution

Test #21:

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

input:

2 9

output:

1 9
##.......

result:

ok good solution

Test #22:

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

input:

3 7

output:

1 14
.##.##.##.....

result:

ok good solution

Test #23:

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

input:

3 8

output:

1 16
.##.##.##.......

result:

ok good solution

Test #24:

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

input:

3 10

output:

1 20
.##.##.##...........

result:

ok good solution

Test #25:

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

input:

4 7

output:

1 7
.##.##.

result:

ok good solution

Test #26:

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

input:

4 9

output:

1 9
.##.##...

result:

ok good solution

Test #27:

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

input:

5 6

output:

-1 -1

result:

ok no solution

Test #28:

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

input:

5 8

output:

1 16
.##.##.##.##.##.

result:

ok good solution

Test #29:

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

input:

5 9

output:

1 18
.##.##.##.##.##...

result:

ok good solution

Test #30:

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

input:

6 7

output:

-1 -1

result:

ok no solution

Test #31:

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

input:

7 8

output:

-1 -1

result:

ok no solution

Test #32:

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

input:

8 9

output:

-1 -1

result:

ok no solution

Test #33:

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

input:

9 10

output:

-1 -1

result:

ok no solution

Extra Test:

score: 0
Extra Test Passed