QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#245389#7637. Exactly Three Neighborsucup-team2307WA 0ms3780kbC++174.1kb2023-11-09 21:19:232023-11-09 21:19:24

Judging History

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

  • [2023-11-09 21:19:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3780kb
  • [2023-11-09 21:19:23]
  • 提交

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);
    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: 0ms
memory: 3616kb

input:

2 3

output:

1 3
##.

result:

ok good solution

Test #2:

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

input:

1 1

output:

-1 -1

result:

ok no solution

Test #3:

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

input:

3 4

output:

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

result:

ok good solution

Test #4:

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

input:

3 5

output:

10 4
.##.
.##.
.##.
.##.
.##.
.##.
.##.
####
#..#
####

result:

ok good solution

Test #5:

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

input:

4 5

output:

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

result:

ok good solution

Test #6:

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

input:

7 10

output:

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

result:

ok good solution

Test #7:

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

input:

5 7

output:

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

result:

ok good solution

Test #8:

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

input:

7 9

output:

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

result:

ok good solution

Test #9:

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

input:

0 1

output:

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

result:

wrong answer the total share of black squares must be 0/1, but your plan is 7/9