# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
570885 |
2022-05-31T13:40:12 Z |
AGE |
Konj (COCI19_konj) |
C++14 |
|
301 ms |
40584 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;
map< pair<int,int> , vector< pair< int,int> > > adj;
map< pair< int,int> , int > vis;
int a[N],b[N],c[N],d[N],ans[301][301];
void dfs(int xnode,int ynode){
vis[{xnode,ynode}]=1;
for(auto x:adj[{xnode,ynode}]){
if(vis[x])
continue;
dfs(x.F,x.S);
}
}
main(){
int n;
cin>>n;
maxx=-1e18,minx=1e18,miny=1e18,maxy=-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],c[i]);j<=max(a[i],c[i]);j++){
for(int k=min(b[i],d[i]);k<=max(b[i],d[i]);k++){
if(j==x&&k==y){
dfs(a[i],b[i]),dfs(c[i],d[i]);
continue;
}
}
}
}
for(int i=0;i<n;i++){
if(!vis[{a[i],b[i]}]&&!vis[{c[i],d[i]}])
continue;
maxx=max(maxx,max(a[i],c[i]));
maxy=max(maxy,max(b[i],d[i]));
minx=min(minx,min(a[i],c[i]));
miny=min(miny,min(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;
}
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:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
24 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
301 ms |
40584 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |