QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245386 | #7637. Exactly Three Neighbors | ucup-team2307 | RE | 1ms | 3464kb | C++17 | 4.0kb | 2023-11-09 21:17:56 | 2023-11-09 21:17:56 |
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";
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);
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";
// }
// }
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3428kb
input:
2 3
output:
1 3 ##.
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
1 1
output:
-1 -1
result:
ok no solution
Test #3:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
3 4
output:
4 4 .##. #### #..# ####
result:
ok good solution
Test #4:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
3 5
output:
10 4 .##. .##. .##. .##. .##. .##. .##. #### #..# ####
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
4 5
output:
5 5 ###.# #.### ####. ##.## .####
result:
ok good solution
Test #6:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
7 10
output:
5 4 .##. .##. #### #..# ####
result:
ok good solution
Test #7:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
5 7
output:
14 4 .##. .##. .##. #### #..# #### .##. #### #..# #### .##. #### #..# ####
result:
ok good solution
Test #8:
score: -100
Runtime Error
input:
7 9