Submission #260411

# Submission time Handle Problem Language Result Execution time Memory
260411 2020-08-10T08:33:29 Z stefantaga Tower Defense (CEOI19_towerdefense) C++14
53 / 100
1 ms 416 KB
#include <bits/stdc++.h>

using namespace std;
int x,y,x2,y2,dist,nr,sensx,sensy,val,i;
int main()
{
    cin>> x2 >> y2;
    cin>> x >> y;
    cin>>nr;
    dist=abs(x-x2)+abs(y-y2);
    if (dist>nr)
    {
        cout<<"impossible";
        return 0;
    }
    if (dist==nr)
    {
        cout<<"0";
        return 0;
    }
    if (dist==1)
    {
        cout<<"impossible";
        return 0;
    }
    if ((nr-dist)%2==1)
    {
        cout<<"impossible";
        return 0;
    }
    if (x!=x2&&y!=y2)
    {
        if (x<x2)
        {
            sensx=-1;
        }
        else
        {
            sensx=1;
        }
        if (y<y2)
        {
            sensy=-1;
        }
        else
        {
            sensy=1;
        }
        if (dist==2&&nr<dist+4)
        {
            cout<<"impossible";
            return 0;
        }
        if (dist==2)
        {
            val=(nr-dist-4)/2+1;
        }
        else
        {
           val=(nr-dist)/2;
        }
        cout<<val*2<<'\n';
        for (i=1;i<=val;i++)
        {
            cout<<x2+sensx*i<<" "<<y2<<'\n';
            cout<<x2<<" "<<y2+sensy*i<<'\n';
        }
    }
    else
    if (y==y2)
    {
        if (x<x2)
        {
            sensx=-1;
        }
        else
        {
            sensx=1;
        }
        val=(nr-dist)/2;
        cout<<2*(val-1)+1<<'\n';
        cout<<x2+sensx<<" "<<y<<'\n';
        for (i=2;i<=val;i++)
        {
            cout<<x2+sensx<<" "<<y-i+1<<'\n';
            cout<<x2+sensx<<" "<<y+i-1<<'\n';
        }
    }
    else
    if (x==x2)
    {
        if (y<y2)
        {
            sensy=-1;
        }
        else
        {
            sensy=1;
        }
        val=(nr-dist)/2;
        cout<<2*(val-1)+1<<'\n';
        cout<<x2<<" "<<y+sensy<<'\n';
        for (i=2;i<=val;i++)
        {
            cout<<x2-i+1<<" "<<y+sensy<<'\n';
            cout<<x2+i-1<<" "<<y+sensy<<'\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 416 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 360 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 0 ms 256 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 416 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 360 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 0 ms 256 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 1 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
39 Correct 0 ms 288 KB Output is correct
40 Incorrect 1 ms 256 KB Distance from entrance to home is not d.
41 Halted 0 ms 0 KB -