QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519061 | #7758. Painter | qqbb# | TL | 0ms | 3592kb | C++20 | 3.4kb | 2024-08-14 15:50:54 | 2024-08-14 15:50:55 |
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;
int s_toi(string s){
int ans=0;
if(s[0] == '-'){
int res=1;
for(int i=s.size()-1;i>0;i--){
ans += (s[i] - '0') * res;
res*=10;
}
return -ans;
}
else{
int res=1;
for(int i=s.size()-1;i>=0;i--){
ans += (s[i] - '0') * res;
res*=10;
}
return ans;
}
}
void solve(){
int n;cin>>n;
vector<array<string,6>> op(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;
string 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] = {s,to_string(x),to_string(y),to_string(r),p,"0"};
}
else if(s == "Rectangle"){
int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
string p;cin>>p;
lo=min(lo,y1);
le=min(le,x1);
hi=max(hi,y2);
ri=max(ri,x2);
op[i] = {s,to_string(x1),to_string(y1),to_string(x2),to_string(y2),p};
}
else{
int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
op[i] = {s,to_string(x1),to_string(y1),to_string(x2),to_string(y2),"0"};
}
}
vector<vector<string>> mp(ri - le + 1,vector<string> (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] = ".";
}
}
cerr<<endl;
for(int i=1;i<=n;i++){
if(op[i][0] == "Circle"){
int u=s_toi(op[i][1])-le;
int v=s_toi(op[i][2])-lo;
int r=s_toi(op[i][3]);
for(int x=0;x<mpx;x++){
for(int y=0;y<mpy;y++){
if((x-u)*(x-u) + (y-v)*(y-v) <= r*r){
mp[x][y] = op[i][4];
}
}
}
}
else if(op[i][0] == "Rectangle"){
int x1=s_toi(op[i][1])-le;
int y1=s_toi(op[i][2])-lo;
int x2=s_toi(op[i][3])-le;
int y2=s_toi(op[i][4])-lo;
for(int x=x1;x<=x2;x++){
for(int y=y1;y<=y2;y++){
mp[x][y] = op[i][5];
}
}
}
else{
int x1=s_toi(op[i][1])-le;
int y1=s_toi(op[i][2])-lo;
int x2=s_toi(op[i][3])-le;
int y2=s_toi(op[i][4])-lo;
for(int y=y2;y>=y1;y--){
for(int x=x1;x<=x2;x++){
cout<<mp[x][y];
}
cout<<endl;
}
}
}
// AA
// for(int i=0;i<mpx;i++){
// for(int j=0;j<mpy;j++){
// cerr<<mp[i][j];
// }
// cerr<<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: 3592kb
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
Time 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:
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW...