QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519084 | #7758. Painter | qqbb# | ML | 0ms | 3808kb | C++20 | 3.2kb | 2024-08-14 16:09:56 | 2024-08-14 16:09:56 |
Judging History
answer
#include <bits/stdc++.h>
#define qqbb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define int long long
#define endl '\n'
#define lb(x) x & -x
#define AA cerr<<"AA"<<endl;
using namespace std;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 4e5 + 10;
void solve(){
int n;cin>>n;
vector<array<char,2>> op(n+1);
vector<array<int,4>> opp(n+1);
int lo=inf,le=inf;
int hi=-inf,ri=-inf;
for(int i=1;i<=n;i++){
string s;cin>>s;
if(s == "Circle"){
int x,y,r;cin>>x>>y>>r;
char p;cin>>p;
lo=min(lo,y-r);
le=min(le,x-r);
hi=max(hi,y+r);
ri=max(ri,x+r);
op[i][0] = 'A';
op[i][1] = p;
opp[i][0]=x;
opp[i][1]=y;
opp[i][2]=r;
opp[i][3]=0;
}
else if(s == "Rectangle"){
int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
char p;cin>>p;
lo=min(lo,y1);
le=min(le,x1);
hi=max(hi,y2);
ri=max(ri,x2);
op[i][0] = 'B';
op[i][1] = p;
opp[i][0]=x1;
opp[i][1]=y1;
opp[i][2]=x2;
opp[i][3]=y2;
}
else{
int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
lo=min(lo,y1);
le=min(le,x1);
hi=max(hi,y2);
ri=max(ri,x2);
op[i][0] = 'C';
op[i][1] = '.';
opp[i][0]=x1;
opp[i][1]=y1;
opp[i][2]=x2;
opp[i][3]=y2;
}
}
vector<vector<char>> mp(ri - le + 1,vector<char> (hi - lo + 1));
int mpx = ri - le + 1;
int mpy = hi - lo + 1;
for(int i=0;i<mpx;i++){
for(int j=0;j<mpy;j++){
mp[i][j] = '.';
}
}
for(int i=1;i<=n;i++){
if(op[i][0] == 'A'){
int u=opp[i][0]-le;
int v=opp[i][1]-lo;
int r=opp[i][2];
for(int x=u-r;x<=u+r;x++){
for(int y=v-r;y<=v+r;y++){
if((x-u)*(x-u) + (y-v)*(y-v) <= r*r){
mp[x][y] = op[i][1];
}
}
}
}
else if(op[i][0] == 'B'){
int x1=opp[i][0]-le;
int y1=opp[i][1]-lo;
int x2=opp[i][2]-le;
int y2=opp[i][3]-lo;
for(int x=x1;x<=x2;x++){
for(int y=y1;y<=y2;y++){
mp[x][y] = op[i][1];
}
}
}
else{
int x1=opp[i][0]-le;
int y1=opp[i][1]-lo;
int x2=opp[i][2]-le;
int y2=opp[i][3]-lo;
for(int y=y2;y>=y1;y--){
for(int x=x1;x<=x2;x++){
// if(x<0 || y<0 || x > mpx || y > mpy){
// cout<<'.';
// }
cout<<mp[x][y];
}
cout<<endl;
}
}
}
}
signed main(){
qqbb;
// cout<<fixed<<setprecision(0);
int Test=1;
// cin>>Test;
while(Test--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
7 Circle 0 0 5 * Circle -2 2 1 @ Circle 2 2 1 @ Rectangle 0 -1 0 0 ^ Rectangle -2 -2 2 -2 _ Render -5 -5 5 5 Render -1 0 1 2
output:
.....*..... ..*******.. .**@***@**. .*@@@*@@@*. .**@***@**. *****^***** .****^****. .**_____**. .*********. ..*******.. .....*..... @*@ *** *^*
result:
ok 14 lines
Test #2:
score: -100
Memory Limit Exceeded
input:
10 Rectangle -4262 2204 3116 9357 U Circle 7078 6883 4684 W Rectangle 390 675 1195 1251 = Rectangle 78 2138 3288 2570 5 Rectangle -874 797 -99 1440 3 Render 7261 -4311 7304 -4268 Render 2060 9253 2103 9296 Render -1379 -7141 -1336 -7098 Render 982 5708 1025 5751 Render 1080 -9592 1123 -9549
output:
............................................ ............................................ ............................................ ............................................ ............................................ ............................................ .................................