Submission #106256

#TimeUsernameProblemLanguageResultExecution timeMemory
106256hamzqq9Konj (COCI19_konj)C++14
70 / 70
92 ms17528 KiB
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<ii,int> #define iiii pair<ii,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)/2) #define all(x) x.begin(),x.end() #define pw(x) (1<<(x)) #define inf 100000009 #define MOD 998244353 #define N 200005 #define M 2500005 #define LOG 20 #define KOK 300 #define EPS 0.0000001 using namespace std; int n,x,y; int mnx=inf,mny=inf,mxx=-inf,mxy=-inf; char a[305][305]; int vis[N]; vector<int> has[305][305]; pair<ii,ii> cur[N]; bool inside(int w) { bool res=true; res&=(x>=min(cur[w].st.st,cur[w].nd.st)); res&=(x<=max(cur[w].st.st,cur[w].nd.st)); res&=(y>=min(cur[w].st.nd,cur[w].nd.nd)); res&=(y<=max(cur[w].st.nd,cur[w].nd.nd)); return (cur[w].st.st-x)*(cur[w].st.nd-cur[w].nd.nd)==(cur[w].st.nd-y)*(cur[w].st.st-cur[w].nd.st) && res; } void doit(int fx,int fy,int sx,int sy) { int g=__gcd(abs(fx-sx),abs(fy-sy)); int dx=abs(fx-sx)/g; int dy=abs(fy-sy)/g; if(fx>sx || fy>sy) { swap(fx,sx); swap(fy,sy); } for(;fx<=sx && fy<=sy;fx+=dx,fy+=dy) { a[fx][fy]='#'; umin(mnx,fx); umax(mxx,fx); umin(mny,fy); umax(mxy,fy); } } void dfs(int w) { if(vis[w]) return ; vis[w]=1; int fx=cur[w].st.st; int fy=cur[w].st.nd; int sx=cur[w].nd.st; int sy=cur[w].nd.nd; doit(fx,fy,sx,sy); while(sz(has[fx][fy])) { int go=has[fx][fy].back(); has[fx][fy].ppb(); dfs(go); } while(sz(has[sx][sy])) { int go=has[sx][sy].back(); has[sx][sy].ppb(); dfs(go); } } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { int a,b,c,d; scanf("%d %d %d %d",&a,&b,&c,&d); cur[i]={{a,b},{c,d}}; has[a][b].pb(i); has[c][d].pb(i); } scanf("%d %d",&x,&y); for(int i=1;i<=n;i++) { if(inside(i)) { dfs(i); } } for(int j=mxy;j>=mny;j--) { for(int i=mnx;i<=mxx;i++) { if(a[i][j]!='#') a[i][j]='.'; printf("%c",a[i][j]); } printf("\n"); } }

Compilation message (stderr)

konj.cpp: In function 'int main()':
konj.cpp:113:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
konj.cpp:119:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d",&a,&b,&c,&d);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
konj.cpp:128:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&x,&y);
  ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...