# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
570883 |
2022-05-31T13:36:20 Z |
AGE |
Konj (COCI19_konj) |
C++14 |
|
1000 ms |
42228 KB |
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define int long long
using namespace std;
const int N=1e6,M=2e3;
int maxx,maxy,minx,miny;
int a[N],b[N],c[N],d[N];
map< pair<int,int>, int> vis;
map< pair<int,int> , vector< pair<int,int> > > adj;
int ans[301][301];
void dfs(int xnode,int ynode){
vis[{xnode,ynode}]=1;
for(auto x:adj[{xnode,ynode}]){
if(vis[x]==1)
continue;
dfs(x.F,x.S);
}
}
main()
{
int n;
cin>>n;
maxx=-1e18,minx=1e18,maxy=-1e18,miny=1e18;
for(int i=0;i<n;i++){
cin>>a[i]>>b[i]>>c[i]>>d[i];
adj[{a[i],b[i]}].pb({c[i],d[i]});
adj[{c[i],d[i]}].pb({a[i],b[i]});
}
int x,y;
cin>>x>>y;
ans[x][y]=1;
for(int i=0;i<n;i++){
for(int j=min(a[i],b[i]);j<=max(a[i],b[i]);j++){
for(int k=min(c[i],d[i]);k<=max(c[i],d[i]);k++){
if(j==x&&k==y)
dfs(min(a[i],b[i]),min(c[i],d[i])),dfs(max(a[i],b[i]),max(c[i],d[i]));
}
}
}
for(int i=0;i<n;i++){
if(!vis[{min(a[i],c[i]),min(b[i],d[i])}]&&!vis[{max(a[i],c[i]),max(b[i],d[i])}])
continue;
minx=min(minx,min(a[i],c[i]));
miny=min(miny,min(b[i],d[i]));
maxx=max(maxx,max(a[i],c[i]));
maxy=max(maxy,max(b[i],d[i]));
for(int j=min(a[i],c[i]);j<=max(a[i],c[i]);j++){
for(int k=min(b[i],d[i]);k<=max(b[i],d[i]);k++){
ans[j][k]=1;
}
}
}
for(int j=maxy;j>=miny;j--){
for(int i=minx;i<=maxx;i++){
if(ans[i][j]==1)
cout<<"#";
else cout<<".";
}
cout<<endl;
}
return 0;
}
/*
2 2 6 2
2 2 2 6
6 2 6 4
6 4 6 6
2 6 6 6
6 2 8 2
8 2 10 2
10 2 12 2
12 2 12 4
12 4 6 4
6 2 6 1
8 2 8 0
10 2 10 1
12 2 12 0
42 42 42 43
2 2
*/
Compilation message
konj.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
30 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Execution timed out |
1010 ms |
42228 KB |
Time limit exceeded |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
6 |
Correct |
1 ms |
444 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |