답안 #260404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260404 2020-08-10T08:26:05 Z stefantaga Tower Defense (CEOI19_towerdefense) C++14
25 / 100
1 ms 384 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";
        cout<<"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;
        }
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 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 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Incorrect 0 ms 256 KB Expected but did not find "impossible".
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 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 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 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 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 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 Incorrect 0 ms 256 KB Expected but did not find "impossible".
22 Halted 0 ms 0 KB -