TAG- 一眼丁真、鉴定为纯纯大水题 一眼丁真、鉴定为纯纯大水题 一眼丁真、鉴定为纯纯大水题时间复杂度- O ( N ∗ 1 0 4 ) O(N \ast 10^4) O(N∗104)
//
#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
这篇文章介绍了M.Painter中的图形绘制功能,涉及圆形和矩形的处理,以及如何在给定坐标范围内进行渲染,时间复杂度讨论了O(N*10^4)。
337

被折叠的 条评论
为什么被折叠?



