每日一题 - 231124 - M. Painter

这篇文章介绍了M.Painter中的图形绘制功能,涉及圆形和矩形的处理,以及如何在给定坐标范围内进行渲染,时间复杂度讨论了O(N*10^4)。

  • TAG - 一眼丁真、鉴定为纯纯大水题 一眼丁真、鉴定为纯纯大水题 一眼丁真、鉴定为纯纯大水题
  • 时间复杂度 - O ( N ∗ 1 0 4 ) O(N \ast 10^4) O(N104)
//
#include<bits/stdc++.h>
using namespace std;
#define int long long

const string s1="Circle";
const string s2="Rectangle";
const string s3="Render";

struct A{ int f,a,b,c,d; char ch; };
vector<A> v;

void solve()
{
    string s;
    cin>>s;

    if( s==s1 )
    {
        int x,y,r;
        char ch;
        cin>>x>>y>>r>>ch;
        v.push_back( (A){ 1,x,y,r,0,ch } );
    }
    else if( s==s2 )
    {
        int a,b,c,d;
        char ch;
        cin>>a>>b>>c>>d>>ch;
        v.push_back( (A){ 2,a,b,c,d,ch } );
    }
    else if( s==s3 )
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        
        for( int j=d;j>=b;j-- )
        {
            for( int i=a;i<=c;i++ )
            {
                char ch='.';
                for( auto it=v.rbegin();it!=v.rend();it++ )
                {
                    if( it->f==1 )
                    {
                        int x=it->a,y=it->b,r=it->c;
                        if( (i-x)*(i-x)+(j-y)*(j-y)<=r*r ) { ch=it->ch; break; }
                    }
                    else if( it->f==2 )
                    {
                        int a1=it->a,b1=it->b,c1=it->c,d1=it->d;
                        if( i>=a1 && i<=c1 && j>=b1 && j<=d1 ) { ch=it->ch; break; }
                    }
                }
                putchar(ch);
            }
            putchar('\n');
        }
    }
}

signed main()
{
    int t=1;
    scanf("%lld",&t );
    while( t-- ) solve();
    return 0;
}
/*

注意到:
	'\t' == 9 
	'\n' == 10
	 ' ' == 32

7
Circle 0 0 5 *
Circle -2 2 1 1
Circle 2 2 1 2
Rectangle 0 -1 0 0 ^
Rectangle -2 -2 2 -2 _
Render -5 -5 5 5
Render -1 0 1 2

    (1)
    ---> y
    |
    x
        i: 1 - n
            j: 1 - n
    (2)
    y
    ^
    |--> x
        j: n - 1
            i: 1 - n
*/

实现细节

  • 坐标轴的变换

参考示意图


参考链接


作者 | 乐意奥AI

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值