# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
226693 | 2020-04-24T22:13:07 Z | DavidDamian | Konj (COCI19_konj) | C++11 | 92 ms | 9336 KB |
#include <bits/stdc++.h> using namespace std; void Sort(int& a,int& b,int& c,int& d) { if(c<a){ swap(a,c); swap(b,d); return; } else{ if(c==a){ if(d<b){ swap(a,c); swap(b,d); } } } } struct line{ int a,b,c,d; } A[200005]; int n; vector<int> bucket[305][305]; int color[200005]; int paint[305][305]; int x,y; queue<int> Q; void bfs() { while(Q.size()){ int u=Q.front(); Q.pop(); for(int v: bucket[ A[u].b ][ A[u].a ]){ if(color[v]==0){ color[v]=1; Q.push(v); } } for(int v: bucket[ A[u].d ][ A[u].c ]){ if(color[v]==0){ color[v]=1; Q.push(v); } } } } void print(int a,int b,int c,int d) { if(a==c){ for(int i=b;i<=d;i++){ paint[i][a]=1; } } else{ for(int j=a;j<=c;j++){ paint[b][j]=1; } } } bool nothingRow(int i) { for(int j=0;j<300;j++){ if(paint[i][j]==1) return false; } return true; } bool nothingCol(int j) { for(int i=0;i<300;i++){ if(paint[i][j]==1) return false; } return true; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n; for(int i=0;i<n;i++){ int a,b,c,d; cin>>a>>b>>c>>d; a=a-1; b=300-b; c=c-1; d=300-d; A[i]={a,b,c,d}; bucket[b][a].push_back(i); bucket[d][c].push_back(i); } cin>>x>>y; x=x-1; y=300-y; for(int i=0;i<n;i++){ Sort(A[i].a,A[i].b,A[i].c,A[i].d); if(A[i].a==A[i].c && A[i].a==x){ if(A[i].b<=y && y<=A[i].d){ color[i]=1; Q.push(i); } } else if(A[i].b==A[i].d && A[i].b==y){ if(A[i].a<=x && x<=A[i].c){ color[i]=1; Q.push(i); } } } bfs(); for(int i=0;i<n;i++){ if(color[i]==1){ //Visited print(A[i].a,A[i].b,A[i].c,A[i].d); } } int firstRow,firstCol,lastRow,lastCol; for(int i=0;i<305;i++){ if(!nothingRow(i)){ firstRow=i; break; } } for(int i=304;i>=0;i--){ if(!nothingRow(i)){ lastRow=i; break; } } for(int j=0;j<305;j++){ if(!nothingCol(j)){ firstCol=j; break; } } for(int j=304;j>=0;j--){ if(!nothingCol(j)){ lastCol=j; break; } } for(int i=firstRow;i<=lastRow;i++){ for(int j=firstCol;j<=lastCol;j++){ if(paint[i][j]==1) cout<<'#'; else cout<<'.'; } cout<<'\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2432 KB | Output is correct |
2 | Correct | 6 ms | 2560 KB | Output is correct |
3 | Incorrect | 92 ms | 9336 KB | Output isn't correct |
4 | Correct | 6 ms | 2560 KB | Output is correct |
5 | Correct | 6 ms | 2560 KB | Output is correct |
6 | Correct | 6 ms | 2560 KB | Output is correct |
7 | Correct | 6 ms | 2560 KB | Output is correct |
8 | Correct | 6 ms | 2560 KB | Output is correct |
9 | Correct | 6 ms | 2560 KB | Output is correct |
10 | Correct | 6 ms | 2560 KB | Output is correct |