The second "intelligence Cup" National College Students' IT skills competition (synchronized with the final)

Keywords: Simulation

T130013 garden party seal

Title Description

The College held a garden tour, in which a very important link is to collect seals. The stamp collection card is a piece of white paper with height and width of \ (h,w(20\le h \le 1000,50\le w \le 2000) \). Initially, each unit pixel is filled with (representing white).

Now little A is stamping on A booth. Because Xiao A likes the style of this stall seal very much, he will seal \ (n(1\le n \le 2000) \) times in succession. The seal is 50 wide and 20 high, as follows:

...........................,]]OOO@@@@OOO]`........
....................,]OO@@@@@@@@@@@@@@@@@@@@O`....
................./O@@@@@@@@@@@@@@@@@@@@@@@@@@@@^..
............../O@@@@@@@@@@@@@@@OOOOOOO@@@@@@@@@@@.
..........,/@@@@@@@@@@@@O/[.............[O@@@@@@@\
........,O@@@@@@@@@@O/`..................,O@@@@@@O
.......O@@@@@@@@@O`......]OO@@@O\`........O@@@@@@@
.....,O@@@@@@@@/`.....]O@@@@@@@@@@^.......O@@@@@@@
...,/@@@@@@@O/...../@@@@@@@@@@@@@@O....../@@@@@@@0
..=@@@@@@@O`...../@@@@@@@@@@@@@@@@^.....O@@@@@@@O.
./@@@@@@@/......O@@@@@@@@@@@@@@@O`..../@@@@@@@@O..
=@@@@@@@O......O@@@@@@@@@@@@@@@^....O@@@@@@@@@O...
O@@@@@@@^.....=@@@@@@@@@@@@@O[..../@@@@@@@@@O`....
@@@@@@@O.......\@@@@@@@@O[...../O@@@@@@@@@O`......
@@@@@@@@^.........[`.......]OO@@@@@@@@@@O`........
O@@@@@@@@O\............]/@@@@@@@@@@@@O/...........
=@@@@@@@OOOoo`........O@@@@@@@@@@@@/`.............
..\OOOOO*,`*..........O@@@@@@@@@O`................
.....,[[..............O@@@@@@O`...................
......................O@@@@@@O....................

Because the hand is not stable when sealing, it is possible to rotate the pattern 180 ° (of course, different characters only represent different colors, and the characters themselves do not need to be turned over).

Now you know the \ (n \) seal information of Xiao A, including the upper left coordinate \ (x,y \), and the rotation mode \ (r \). That is, the upper left corner of the rotated pattern is located at the position of the \ (x \) row \ (Y \) column of the chapter card, and the coordinate of the upper left corner of the chapter card is \ ((0,0) \).

It should be noted that the seal on the back cover may overlap with the seal changed before. The colored part of the chapter on the back cover (not the part of) will overwrite the previously printed figure.

Input format

The three integers \ (n,h,w \) in the first line represent the number of seals and the height and width of the stamp collection card.

Next \ (n \) lines, three integers \ (x,y,r \) per line, describe the information stamped each time. Where \ ((x,y) \) is the coordinate of the upper left corner of the pattern (after rotation), \ (r(0\le r\le 1) \) represents the rotation mode, and represents the clockwise rotation of the pattern \ (r\times 180\degree \). Ensure that at least part of the seal pattern is inside the stamp collection card.

Output format

Output a character matrix with a height of \ (h \) and a width of \ (w \) to represent the appearance of all stamped stamp collection cards. Spaces at the end of the line and carriage returns at the end of the output file are ignored during profiling.

input

2 37 70
2 2 0
15 18 1

output

......................................................................
......................................................................
.............................,]]OOO@@@@OOO]`..........................
......................,]OO@@@@@@@@@@@@@@@@@@@@O`......................
.................../O@@@@@@@@@@@@@@@@@@@@@@@@@@@@^....................
................/O@@@@@@@@@@@@@@@OOOOOOO@@@@@@@@@@@...................
............,/@@@@@@@@@@@@O/[.............[O@@@@@@@\..................
..........,O@@@@@@@@@@O/`..................,O@@@@@@O..................
.........O@@@@@@@@@O`......]OO@@@O\`........O@@@@@@@..................
.......,O@@@@@@@@/`.....]O@@@@@@@@@@^.......O@@@@@@@..................
.....,/@@@@@@@O/...../@@@@@@@@@@@@@@O....../@@@@@@@0..................
....=@@@@@@@O`...../@@@@@@@@@@@@@@@@^.....O@@@@@@@O...................
.../@@@@@@@/......O@@@@@@@@@@@@@@@O`..../@@@@@@@@O....................
..=@@@@@@@O......O@@@@@@@@@@@@@@@^....O@@@@@@@@@O.....................
..O@@@@@@@^.....=@@@@@@@@@@@@@O[..../@@@@@@@@@O`......................
..@@@@@@@O.......\@@@@@@@@O[...../O@@@O@@@@@@O........................
..@@@@@@@@^.........[`.......]OO@@@@@`O@@@@@@O..............[[,.......
..O@@@@@@@@O\............]/@@@@@@@`O@@@@@@@@@O..........*`,*OOOOO\....
..=@@@@@@@OOOoo`........O@@@@@@`/@@@@@@@@@@@@O........`ooOOO@@@@@@@=..
....\OOOOO*,`*..........O@@@@/O@@@@@@@@@@@@/]............\O@@@@@@@@O..
.......,[[..............O@`O@@@@@@@@@@OO].......`[.........^@@@@@@@@..
........................`O@@@@@@@@@O/.....[O@@@@@@@@\.......O@@@@@@@..
......................`O@@@@@@@@@/....[O@@@@@@@@@@@@@=.....^@@@@@@@O..
.....................O@@@@@@@@@O....^@@@@@@@@@@@@@@@O......O@@@@@@@=..
....................O@@@@@@@@/....`O@@@@@@@@@@@@@@@O....../@@@@@@@/...
...................O@@@@@@@O.....^@@@@@@@@@@@@@@@@/.....`O@@@@@@@=....
..................0@@@@@@@/......O@@@@@@@@@@@@@@/...../O@@@@@@@/,.....
..................@@@@@@@O.......^@@@@@@@@@@O].....`/@@@@@@@@O,.......
..................@@@@@@@O........`\O@@@OO]......`O@@@@@@@@@O.........
..................O@@@@@@O,..................`/O@@@@@@@@@@O,..........
..................\@@@@@@@O[.............[/O@@@@@@@@@@@@/,............
...................@@@@@@@@@@@OOOOOOO@@@@@@@@@@@@@@@O/................
....................^@@@@@@@@@@@@@@@@@@@@@@@@@@@@O/...................
......................`O@@@@@@@@@@@@@@@@@@@@OO],......................
..........................`]OOO@@@@OOO]],.............................
......................................................................
......................................................................

Problem solving ideas

simulation

Initialize the white paper first, and then simulate the overlay~
Note: Chapter. Will not be overwritten

  • Time complexity: \ (O(100\times n) \)

code

#include<bits/stdc++.h>
using namespace std;
char paper[1005][2005];
char stamp[25][55]=
{
"...........................,]]OOO@@@@OOO]`........",
"....................,]OO@@@@@@@@@@@@@@@@@@@@O`....",
"................./O@@@@@@@@@@@@@@@@@@@@@@@@@@@@^..",
"............../O@@@@@@@@@@@@@@@OOOOOOO@@@@@@@@@@@.",
"..........,/@@@@@@@@@@@@O/[.............[O@@@@@@@\\",
"........,O@@@@@@@@@@O/`..................,O@@@@@@O",
".......O@@@@@@@@@O`......]OO@@@O\\`........O@@@@@@@",
".....,O@@@@@@@@/`.....]O@@@@@@@@@@^.......O@@@@@@@",
"...,/@@@@@@@O/...../@@@@@@@@@@@@@@O....../@@@@@@@0",
"..=@@@@@@@O`...../@@@@@@@@@@@@@@@@^.....O@@@@@@@O.",
"./@@@@@@@/......O@@@@@@@@@@@@@@@O`..../@@@@@@@@O..",
"=@@@@@@@O......O@@@@@@@@@@@@@@@^....O@@@@@@@@@O...",
"O@@@@@@@^.....=@@@@@@@@@@@@@O[..../@@@@@@@@@O`....",
"@@@@@@@O.......\\@@@@@@@@O[...../O@@@@@@@@@O`......",
"@@@@@@@@^.........[`.......]OO@@@@@@@@@@O`........",
"O@@@@@@@@O\\............]/@@@@@@@@@@@@O/...........",
"=@@@@@@@OOOoo`........O@@@@@@@@@@@@/`.............",
"..\\OOOOO*,`*..........O@@@@@@@@@O`................",
".....,[[..............O@@@@@@O`...................",
"......................O@@@@@@O...................."
};
int n,h,w,x,y,r;
int main()
{
    for(int i=0;i<=1000;i++)
        for(int j=0;j<=2000;j++)paper[i][j]='.';
    for(scanf("%d%d%d",&n,&h,&w);n;n--)
    {
        scanf("%d%d%d",&x,&y,&r);
        if(r==0)
        {
            for(int i=x;i<min(1001,x+20);i++)
                for(int j=y;j<min(2001,y+50);j++)
                    if(stamp[i-x][j-y]!='.')paper[i][j]=stamp[i-x][j-y];
        }
        else
        {
            for(int i=x;i<min(1001,x+20);i++)
                for(int j=y;j<min(2001,y+50);j++)
                    if(stamp[x-i+19][y-j+49]!='.')paper[i][j]=stamp[x-i+19][y-j+49];
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)putchar(paper[i][j]);
        puts("");
    }
    return 0;
}

P6462 tool repair

Title Description

UIM plays a MOBA game in its spare time of writing programs.

When the enemy's small soldiers enter the range of our defense tower, they will continue to be damaged by the defense tower; Of course, our heroes can also do damage to it. When the minion's HP drops to 0 or lower, it will be killed. In order to gain experience, UIM hopes to kill the soldier before the defense tower kills him.

To simplify the problem, we assume that the soldier has \ (h \) health points. Each attack of the defense tower can cause \ (x \) damage to the soldiers, while each attack of your hero can cause \ (y \) damage to the soldiers. Your attack speed is the same as that of the defense tower, so you can choose whether to attack the small soldier before the defense tower attacks the small soldier for the first time or after each defense tower attack. Of course, you can also choose not to attack.

Now want to know, give this information, judge whether the hero has a way to kill this soldier?

Input format

Each test point consists of multiple sets of data.

Enter the first line containing a positive integer \ (T \) representing the number of data groups.

Next \ (T \) line, each line has three non negative integers \ (h,x,y \), and its meaning has been given in the title description.

Output format

Output \ (T \) line. For each group of data, if you can finally kill the soldiers, output Yes, otherwise output No.

input

5
100 100 1
100 97 1
100 98 1
100 99 1
100 100 0

output

No
No
Yes
Yes
No

Description / tips

The number of groups of data is no more than \ (50 \), \ (1\le h \le 10^{18} \), \ (0\le x,y \le 10^{18} \).

Problem solving ideas

simulation

code

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int t;
LL h,x,y;
int main()
{
    for(scanf("%d",&t);t;t--)
    {
        scanf("%lld%lld%lld",&h,&x,&y);
        if(y==0)puts("No");
        else if(x==0)
            puts("Yes");
        else
        {
            if(y>=h)puts("Yes");
            else
            {
                LL a=(h+x-1)/x;
                a--;
                if(a<=0)puts("No");
                else
                {
                    h=h-a*x;
                    puts(h<=(a+1)*y?"Yes":"No");
                }
            }
        }
    }
    return 0;
}

Posted by tentaguasu on Tue, 02 Nov 2021 14:05:16 -0700