Submission #441147

#TimeUsernameProblemLanguageResultExecution timeMemory
441147zaneyuTower Defense (CEOI19_towerdefense)C++14
53 / 100
2 ms332 KiB
/*input 0 0 4 0 8 */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("Ofast,unroll-loops") //order_of_key #of elements less than x // find_by_order kth element using ll=long long; using ld=long double; using pii=pair<int,int>; #define f first #define s second #define pb push_back #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define FILL(n,x) memset(n,x,sizeof(n)) #define ALL(_a) _a.begin(),_a.end() #define sz(x) (int)x.size() #define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end())))) const ll INF64=1e18+1; const int INF=0x3f3f3f3f; int MOD=1e9+7; const ld PI=acos(-1); const ld eps=1e-3; #define lowb(x) x&(-x) #define MNTO(x,y) x=min(x,(__typeof__(x))y) #define MXTO(x,y) x=max(x,(__typeof__(x))y) inline ll mult(ll a,ll b){ if(a>=MOD) a%=MOD; if(b>=MOD) b%=MOD; return (a*b)%MOD; } inline ll mypow(ll a,ll b){ if(b<=0) return 1; ll res=1LL; while(b){ if(b&1) res=mult(res,a); a=mult(a,a); b>>=1; } return res; } const int maxn=300+5; const int maxlg=__lg(maxn)+2; void die(){ cout<<"impossible"; exit(0); } int32_t main(){ ios::sync_with_stdio(false),cin.tie(0); int x1,y1,x2,y2,d; cin>>x1>>y1>>x2>>y2>>d; int dx=abs(x1-x2),dy=abs(y1-y2); if(dx+dy==1){ die(); } if((dx+dy)%2!=(d%2)) die(); if((dx+dy)>d) die(); if(dx==1 and dy==1){ int z=(d-dx-dy)/2; if(z==1) die(); cout<<(2*(z-1))<<'\n'; REP1(i,z-1) cout<<x1<<' '<<y1+i*(y2-y1)<<'\n'; REP1(i,z-1) cout<<x2<<' '<<y2+i*(y1-y2)<<'\n'; } else if(dx>1){ int z=x1+(x2-x1)/abs(x2-x1); int zd=(d-dx-dy)/2; cout<<(2*zd+dy)<<'\n'; int dd=1; if(y2<y1) dd=-1; REP(i,dy) cout<<z<<' '<<y1+i*dd<<'\n'; REP(i,zd) cout<<z<<' '<<y1+dd*dy+i*dd<<'\n'; REP1(i,zd) cout<<z<<' '<<y1-i*dd<<'\n'; } else{ int z=y1+(y2-y1)/abs(y2-y1); int zd=(d-dx-dy)/2; int dd=1; if(x2<x1) dd=-1; cout<<(2*zd+dx)<<'\n'; REP(i,dx) cout<<x1+i*dd<<' '<<z<<'\n'; REP(i,zd) cout<<x1+dd*dx+i*dd<<' '<<z<<'\n'; REP1(i,zd) cout<<x1-i*dd<<' '<<z<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...