QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245395 | #7637. Exactly Three Neighbors | ucup-team2307 | AC ✓ | 1ms | 3532kb | C++17 | 4.2kb | 2023-11-09 21:23:54 | 2023-11-09 21:23:54 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
bool ask(int p, int q)
{
if (p*5 >= q*4)
{
if (p*5 == q*4)
{
cout<<5<<" "<<5<<"\n";
cout<<"###.#\n";
cout<<"#.###\n";
cout<<"####.\n";
cout<<"##.##\n";
cout<<".####\n";
}
else
{
cout<<-1<<" "<<-1<<"\n";
}
return true;
}
if (p==2)
{
cout<<1<<" "<<q<<"\n";
cout<<"##"<<string(q-2, '.');
cout<<"\n";
return true;
}
for (int x=0; x<=100; x++)
for (int k=1; k<=100; k++)
if (p*(2*x+8*k) == q*(x+6*k))
{
cout<<x+4*k<<" "<<4<<"\n";
for (int i=0; i<x; i++)
cout<<".##.\n";
for (int i=0; i<k; i++)
{
cout<<".##.\n";
cout<<"####\n";
cout<<"#..#\n";
cout<<"####\n";
}
return true;
}
for (int x=0; x<=100; x++)
for (int y=0; y<=100; y++)
if (p*(8+x)*(8+y) == q*(48+4*x+4*y))
{
// exit(1);
vector<vector<char> > v(8+x, vector<char>(8+y, '.'));
for (int i=0; i<8; i++) v[0][i] = ".##.##.."[i];
for (int i=0; i<8; i++) v[1][i] = "###.####"[i];
for (int i=0; i<8; i++) v[2][i] = "#.###.##"[i];
for (int i=0; i<8; i++) v[3][i] = "#######."[i];
for (int i=0; i<8; i++) v[4][i] = "##...##."[i];
for (int i=0; i<8; i++) v[5][i] = "#######."[i];
for (int i=0; i<8; i++) v[6][i] = "#.###.##"[i];
for (int i=0; i<8; i++) v[7][i] = "###.####"[i];
for (int i=8; i<8+y; i++)
{
v[1][i] = '#';
v[2][i] = '#';
v[6][i] = '#';
v[7][i] = '#';
}
for (int i=8; i<8+x; i++)
{
v[i][1] = '#';
v[i][2] = '#';
v[i][4] = '#';
v[i][5] = '#';
}
cout<<8+x<<" "<<8+y<<"\n";
for (int i=0; i<8+x; i++, cout<<"\n")
for (int j=0; j<8+y; j++)
cout<<v[i][j];
return true;
}
{
// if (p==7 && q == 9)
// exit(1);
// cout<<-1<<" "<<-1<<"\n";
vector<string> v;
cout<<18<<" "<<6<<"\n";
v.pb(".####.");
v.pb("###.##");
v.pb("#.####");
v.pb("####..");
v.pb("##.###");
v.pb(".#####");
v.pb("###..#");
v.pb("#.####");
v.pb("#####.");
v.pb("##..##");
v.pb(".#####");
v.pb("####.#");
v.pb("#..###");
v.pb("#####.");
v.pb("###.##");
v.pb("..####");
v.pb("####.#");
v.pb("##.###");
// int q = 0;
// for (int i=0; i<18; i++, cout<<"\n")
// for (int j=0; j<6; j++)
// if (v[i][j] == '.')
// cout<<".";
// else
// {
// q++;
// int c = 0;
// for (int di=-1; di<=1; di++)
// for (int dj=-1; dj<=1; dj++)
// if (di*dj == 0)
// if (di!=0 || dj!=0)
// {
// if (v[(i+di+18)%18][(j+dj+6)%6] == '#')
// c++;
// }
// cout<<c;
// }
// cout<<q*9<<" "<<18*6*7<<"\n";
for (string s : v)
cout<<s<<"\n";
return true;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int p, q;
cin>>p>>q;
// if (p==7 && q == 9)
// exit(1);
if (p==0)
{
cout<<1<<" "<<1<<"\n";
cout<<".\n";
}
else
ask(p, q);
// for (int p=1; p<=10; p++)
// for (int q=p; q<=10; q++)
// {
// if (__gcd(p, q) == 1)
// {
//// cout<<p<<"/"<<q<<"\n";
// if (!ask(p, q))
// cout<<p<<"/"<<q<<" not found!!!!!!!!!!!!!!!!!!!\n";
// }
// }
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3512kb
input:
2 3
output:
1 3 ##.
result:
ok good solution
Test #2:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
1 1
output:
-1 -1
result:
ok no solution
Test #3:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
3 4
output:
4 4 .##. #### #..# ####
result:
ok good solution
Test #4:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
3 5
output:
10 4 .##. .##. .##. .##. .##. .##. .##. #### #..# ####
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
4 5
output:
5 5 ###.# #.### ####. ##.## .####
result:
ok good solution
Test #6:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
7 10
output:
5 4 .##. .##. #### #..# ####
result:
ok good solution
Test #7:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
5 7
output:
14 4 .##. .##. .##. #### #..# #### .##. #### #..# #### .##. #### #..# ####
result:
ok good solution
Test #8:
score: 0
Accepted
time: 1ms
memory: 3408kb
input:
7 9
output:
18 6 .####. ###.## #.#### ####.. ##.### .##### ###..# #.#### #####. ##..## .##### ####.# #..### #####. ###.## ..#### ####.# ##.###
result:
ok good solution
Test #9:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
0 1
output:
1 1 .
result:
ok good solution
Test #10:
score: 0
Accepted
time: 1ms
memory: 3408kb
input:
1 2
output:
9 40 .##.##.................................. ###.#################################### #.###.################################## #######................................. ##...##................................. #######................................. #.###.################################## ###.####...
result:
ok good solution
Test #11:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
1 3
output:
13 108 .##.##...................................................................................................... ###.######################################################################################################## #.###.#####################################################################...
result:
ok good solution
Test #12:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
1 4
output:
19 80 .##.##.......................................................................... ###.############################################################################ #.###.########################################################################## #######...............................................
result:
ok good solution
Test #13:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
1 5
output:
24 100 .##.##.............................................................................................. ###.################################################################################################ #.###.#####################################################################################...
result:
ok good solution
Test #14:
score: 0
Accepted
time: 1ms
memory: 3412kb
input:
1 6
output:
30 104 .##.##.................................................................................................. ###.#################################################################################################### #.###.#############################################################################...
result:
ok good solution
Test #15:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
1 7
output:
40 84 .##.##.............................................................................. ###.################################################################################ #.###.############################################################################## #######...................................
result:
ok good solution
Test #16:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
1 8
output:
46 96 .##.##.......................................................................................... ###.############################################################################################ #.###.########################################################################################## ###...
result:
ok good solution
Test #17:
score: 0
Accepted
time: 1ms
memory: 3444kb
input:
1 9
output:
52 108 .##.##...................................................................................................... ###.######################################################################################################## #.###.#####################################################################...
result:
ok good solution
Test #18:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
1 10
output:
64 100 .##.##.............................................................................................. ###.################################################################################################ #.###.#####################################################################################...
result:
ok good solution
Test #19:
score: 0
Accepted
time: 0ms
memory: 3408kb
input:
2 5
output:
1 5 ##...
result:
ok good solution
Test #20:
score: 0
Accepted
time: 0ms
memory: 3396kb
input:
2 7
output:
1 7 ##.....
result:
ok good solution
Test #21:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
2 9
output:
1 9 ##.......
result:
ok good solution
Test #22:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
3 7
output:
10 84 .##.##.............................................................................. ###.################################################################################ #.###.############################################################################## #######...................................
result:
ok good solution
Test #23:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
3 8
output:
12 64 .##.##.......................................................... ###.############################################################ #.###.########################################################## #######......................................................... ##...##..............................
result:
ok good solution
Test #24:
score: 0
Accepted
time: 0ms
memory: 3404kb
input:
3 10
output:
15 88 .##.##.................................................................................. ###.#################################################################################### #.###.################################################################################## #######.......................
result:
ok good solution
Test #25:
score: 0
Accepted
time: 1ms
memory: 3412kb
input:
4 7
output:
14 4 .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. #### #..# ####
result:
ok good solution
Test #26:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
4 9
output:
10 54 .##.##................................................ ###.################################################## #.###.################################################ #######............................................... ##...##............................................... #######...............
result:
ok good solution
Test #27:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
5 6
output:
-1 -1
result:
ok no solution
Test #28:
score: 0
Accepted
time: 0ms
memory: 3400kb
input:
5 8
output:
8 4 .##. .##. .##. .##. .##. #### #..# ####
result:
ok good solution
Test #29:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
5 9
output:
18 4 .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. .##. #### #..# ####
result:
ok good solution
Test #30:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
6 7
output:
-1 -1
result:
ok no solution
Test #31:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
7 8
output:
-1 -1
result:
ok no solution
Test #32:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
8 9
output:
-1 -1
result:
ok no solution
Test #33:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
9 10
output:
-1 -1
result:
ok no solution
Extra Test:
score: 0
Extra Test Passed