제출 #1068743

#제출 시각아이디문제언어결과실행 시간메모리
1068743BigBadBullyNaval battle (CEOI24_battle)C++17
0 / 100
30 ms4952 KiB
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
struct ship{
    int x,y;
    char dir;
    
    /*
    Northern — decreases the y coordinate by 1
    Southern — increases the y coordinate by 1
    Eastern — increases the x coordinate by 1
    Western — decreases the x coordinate by 1
    */
};
int calc(ship a, ship b)
{
    
    if (a.dir == b.dir)
        return 0;    
    if (a.x == b.x)
    {
        if (a.y < b.y)
            swap(a,b);
        if (a.dir == 'N' && b.dir == 'S')
            return (a.y-b.y)/2;
        return 0;    
    }
    if (a.y == b.y)
    {
        if (a.x < b.x)
            swap(a,b);
        if (a.dir == 'W' && b.dir == 'E')
            return (a.x-b.x)/2;
        return 0;
    }
    if (a.x + a.y == b.x + b.y)
    {
       if(a.dir == 'N')
       {
           if (b.dir == 'E')
           {
               if (b.x < a.x && a.y > b.y)
                return abs(a.x-b.x);
           }
           else if (b.dir == 'W')
           {
               if (b.x > a.x && a.y > b.y)
                return abs(a.x-b.x);
           }
       }
       else if (a.dir == 'S')
       {
           if (b.dir == 'E')
           {
                 if (b.x < a.x && a.y < b.y)
                return abs(a.x-b.x);
           }
           else if (b.dir == 'W')
           {
                 if (b.x > a.x  && a.y < b.y)
                return abs(a.x-b.x);
           }
       }
       else if (a.dir == 'W')
       {
           if (b.dir == 'N')
           {
               if (b.x < a.x && a.y < b.y)
                return abs(a.x-b.x);
           }
           else if (b.dir == 'S')
           {
               if (b.x < a.x && a.y > b.y)
                return abs(a.x-b.x);
           }
       }
       else if (a.dir == 'E')
       {
          if (b.dir == 'N')
           {
               if (b.x > a.x && a.y < b.y)
                return abs(a.x-b.x);
           }
           else if (b.dir == 'S')
           {
               if (b.x > a.x && a.y > b.y)
                return abs(a.x-b.x);
           }
       }
           
    }
    return 0;
}
signed main() {
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    
    vector<ship> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i].x >> v[i].y >> v[i].dir;
        
    }
    if (n>2)
    {
        cout << "n\n";
        return 0;
    }
    ship c = v[0];
    ship d = v[1];
    if (!calc(c,d))
    {
        cout << "1\n2\n";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...