답안 #260405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260405 2020-08-10T08:28:38 Z stefantaga Tower Defense (CEOI19_towerdefense) C++14
0 / 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<<"impossible";
        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 Incorrect 1 ms 384 KB Expected integer, but "impossible" found
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Incorrect 0 ms 256 KB Expected integer, but "impossible" found
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 384 KB Expected integer, but "impossible" found
3 Halted 0 ms 0 KB -