QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350090#8217. King's Dinnerucup-team1525#WA 1ms4696kbC++172.9kb2024-03-10 14:12:372024-03-10 14:12:39

Judging History

This is the latest submission verdict.

  • [2024-03-10 14:12:39]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 4696kb
  • [2024-03-10 14:12:37]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
int t,n;
const int N=105;
int sum[N],f[N];
char s[N][N][N];
void prework()
{
    for (int n=1;n<=100;++n)
    {
        int ans=0,l=0;
        for (int i=0;i*3-1<=n;++i)
        {
            int sum1=(n+1)/2*i;
            int down=n-i*3+1;
            int downp=down/2;
            int sum2=(n+1)/3*downp;
            if (sum1+sum2>=ans)
            {
                ans=sum1+sum2;
                l=i;
            }
        }
        sum[n]=ans;
        f[n]=l;
        // if (n<=10)cout<<n<<' '<<sum[n]<<' '<<f[n]<<endl;
    }
    for (int n=4;n<=100;++n)
    {
        int p=(n-1)*4;
        int newf=sum[n-4]+p/3;
        if (newf>sum[n])
        {
            // cout<<"!"<<n<<' '<<sum[n]<<' '<<newf<<endl;
            sum[n]=newf;
            f[n]=-1;
        }
    }
}
void build(int n)
{
    for (int i=1;i<=n;++i)
        for (int j=1;j<=n;++j)
            s[n][i][j]='.';
    if (f[n]==-1)
    {
        // build(n-4);
        // for (int i=n-4;i;--i)
        //     for (int j=n-4;j;--j)
        //         s[i+2][j+2]=s[i][j];
        // for (int i=1;i<=n;++i)
        //     s[1][i]=s[2][i]=s[i][1]=s[i][2]='.';
        for (int i=1;i<=n-4;++i)
            for (int j=1;j<=n-4;++j)
                s[n][i+2][j+2]=s[n-4][i][j];
        int p=0;
        for (int i=1;i<=n;++i)
        {
            ++p;
            if (p%3!=0)
                s[n][1][i]='#';
        }
        for (int i=2;i<=n;++i)
        {
            ++p;
            if (p%3!=0)
                s[n][i][n]='#';
        }
        for (int i=n-1;i;--i)
        {
            ++p;
            if (p%3!=0)
                s[n][n][i]='#';
        }
        for (int i=n-1;i>=3;--i)
        {
            ++p;
            if (p%3!=0&&(p%3==2||i!=3))
                s[n][i][1]='#';
        }
    }
    else
    {
        int l=f[n];
        int p=1;
        for (int i=1;i<=l;++i)
        {
            for (int j=1;j<=n;++j)
                if (j%2==1)
                    s[n][p][j]='#';
            ++p;
            for (int j=1;j<=n;++j)
                if (j%2==1)
                    s[n][p][j]='#';
            ++p;
            ++p;
        }
        int r=(n-l*3+1)/2;
        for (int i=1;i<=r;++i)
        {
            for (int j=1;j<=n;++j)
                if (j%3!=0&&(j!=n||n%3==2))
                    s[n][p][j]='#';
            ++p;
            ++p;
        }
    }

}
int main()
{
    prework();
    scanf("%d",&t);
    for (int i=1;i<=100;++i)
        build(i);
    while (t--)
    {
        scanf("%d",&n);
        // n=100;
        // build(n);
        for (int i=1;i<=n;++i)
        {
            for (int j=1;j<=n;++j)
                putchar(s[n][i][j]);
            putchar('\n');
        }
        // cout<<(double)ans/(double)n/(double)n<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4696kb

input:

3
1
2
3

output:

.
#.
#.
#.#
#.#
...

result:

ok all tests correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 4628kb

input:

50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

output:

.
#.
#.
#.#
#.#
...
##.#
...#
#...
#.##
#.#.#
#.#.#
.....
#.#.#
#.#.#
#.#.#.
#.#.#.
......
##.##.
......
##.##.
#.#.#.#
#.#.#.#
.......
#.#.#.#
#.#.#.#
.......
##.##..
#.#.#.#.
#.#.#.#.
........
##.##.##
........
##.##.##
........
##.##.##
#.#.#.#.#
#.#.#.#.#
.........
#.#.#.#.#
#.#.#.#.#
.........
...

result:

wrong answer jury has the better answer: jans = 8, pans = 7 (test case 6)