# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
216896 | 2020-03-28T10:31:25 Z | jzh | Tower Defense (CEOI19_towerdefense) | C++14 | 6 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll sx,sy,ex,ey,i,i1,d,x1,y1,x2,y2,a,b; cin>>sx>>sy>>ex>>ey>>d; vector<pair<ll,ll> >v; if (sy>ey||(sy==ey&&sx>ex)){ swap(sy,ey); swap(sx,ex); } d-=abs(sy-ey)+abs(sx-ex); if (d==0){ cout<<"0\n"; return 0; } else if (d<0||d%2==1){ cout<<"impossible\n"; return 0; } if (abs(sy-ey)+abs(sx-ex)<=1){ cout<<"impossible\n"; return 0; } if (sy+1==ey&&sx+1==ex){ /* E. .H */ if (d<4||d%2==1){ cout<<"impossible\n"; return 0; } d-=4; x1=sx+1; y1=sy; v.push_back({x1,y1}); x2=sx; y2=sy+1; v.push_back({x2,y2}); d/=2; while (d--){ y1--; x2--; v.push_back({x1,y1}); v.push_back({x2,y2}); } } else if (sy+1==ey&&sx-1==ex){ /* .E H. */ if (d<4||d%2==1){ cout<<"impossible\n"; return 0; } d-=4; x1=sx-1; y1=sy; v.push_back({x1,y1}); x2=sx; y2=sy+1; v.push_back({x2,y2}); d/=2; while (d--){ y1--; x2++; v.push_back({x1,y1}); v.push_back({x2,y2}); } } else if (sx==ex){//vertical line //Assume d>0 if (d<2||d%2==1){ cout<<"impossible\n"; return 0; } v.push_back({sx,sy+1}); d-=2; x1=sx; y1=sy+1; x2=sx; y2=sy+1; d/=2; while (d--){ x1++; x2--; v.push_back({x1,y1}); v.push_back({x2,y2}); } } else if (sy==ey){//horizontal line //Assume d>0 if (d<2||d%2==1){ cout<<"impossible\n"; return 0; } v.push_back({sx+1,sy}); d-=2; x1=sx+1; y1=sy; x2=sx+1; y2=sy; d/=2; while (d--){ y1++; y2--; v.push_back({x1,y1}); v.push_back({x2,y2}); } } else if (ex>sx){ /* E. .. .H */ if (ex-sx==1||ey-sy==1)d-=2; else d-=4; if (d<0||d%2==1){ cout<<"impossible\n"; return 0; } d/=2; v.push_back({sx+1,sy}); v.push_back({sx,sy+1}); x1=sx; y1=sy+1; x2=sx+1; y2=sy; if (d!=0){ if (ex-sx==1){ v.push_back({sx-1,sy+1}); d--; x1=sx-1; } if (ey-sy==1){ y2=sy-1; d--; v.push_back({sx+1,sy-1}); } } while (d--){ x1--; y2--; v.push_back({x1,y1}); v.push_back({x2,y2}); } } else if (sx>ex){ /* .E .. H. */ if (sx-ex==1||ey-sy==1)d-=2; else d-=4; if (d<0||d%2==1){ cout<<"impossible\n"; return 0; } d/=2; v.push_back({sx-1,sy}); v.push_back({sx,sy+1}); x1=sx; y1=sy+1; x2=sx-1; y2=sy; if (d!=0){ if (sx-ex==1){ v.push_back({sx+1,sy+1}); x1=sx+1; d--; } if (ey-sy==1){ y2=sy-1; d--; v.push_back({sx-1,sy-1}); } } while (d--){ x1++; y2--; v.push_back({x1,y1}); v.push_back({x2,y2}); } } else assert(false); cout<<v.size()<<'\n'; for (i=0;i<v.size();i++){ cout<<v[i].first<<' '<<v[i].second<<'\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
16 | Correct | 4 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 4 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 4 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 4 ms | 384 KB | Output is correct |
27 | Correct | 4 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 308 KB | Output is correct |
29 | Correct | 4 ms | 384 KB | Output is correct |
30 | Correct | 6 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
16 | Correct | 4 ms | 384 KB | Output is correct |
17 | Correct | 4 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 4 ms | 384 KB | Output is correct |
21 | Correct | 4 ms | 384 KB | Output is correct |
22 | Correct | 4 ms | 384 KB | Output is correct |
23 | Correct | 4 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 4 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 4 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 4 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 4 ms | 384 KB | Output is correct |
34 | Correct | 4 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 308 KB | Output is correct |
36 | Correct | 4 ms | 384 KB | Output is correct |
37 | Correct | 6 ms | 256 KB | Output is correct |
38 | Correct | 5 ms | 384 KB | Output is correct |
39 | Incorrect | 4 ms | 384 KB | Expected integer, but "impossible" found |
40 | Halted | 0 ms | 0 KB | - |