# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113602 | EfeBabagil | Naval battle (CEOI24_battle) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
using namespace std;
#include <bits/stdc++.h>
#define int long long
int32_t main()
{
int n;
cin>>n;
vector<array<int,3>> ships(n);
vector<array<int,3>> x;
vector<int> sunk(n,LLONG_MAX);
for(int i=0;i<n;i++)
{
int a,b;
char c;
cin>>a>>b;
cin>>c;
ships[i]={a,b,c};
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(ships[i][2]==ships[j][2])
continue;
if(ships[i][2]=='S'&&ships[j][2]=='N'ships[i][1]<ships[j][1])
{
if(ships[i][0]==ships[j][0])
{
x.push_back({abs(ships[i][1]-ships[j][1])/2,i,j});
}
}
if(ships[i][2]=='E'&&ships[j][2]=='W'&&ships[i][0]<ships[j][0])
{
if(ships[i][1]==ships[j][1])
{
x.push_back({abs(ships[i][0]-ships[j][0])/2,i,j});
}
}
if( ships[i][2]=='S'&&ships[j][2]=='W')
{
if(ships[i][0]-ships[i][1]==ships[j][0]-ships[j][1]&&ships[i][1]<ships[j][1])
{
x.push_back({abs(ships[i][1]-ships[j][1]),i,j});
}
}
if(ships[i][2]=='S'&&ships[j][2]=='E')
{
if(ships[i][0]+ships[i][1]==ships[j][0]+ships[j][1]&&ships[i][1]<ships[j][1])
{
x.push_back({abs(ships[i][1]-ships[j][1]),i,j});
}
}
if( ships[i][2]=='N'&&ships[j][2]=='E')
{
if(ships[i][0]-ships[i][1]==ships[j][0]-ships[j][1]&&ships[i][1]>ships[j][1])
{
x.push_back({abs(ships[i][1]-ships[j][1]),i,j});
}
}
if(ships[i][2]=='N'&&ships[j][2]=='W')
{
if(ships[i][0]+ships[i][1]==ships[j][0]+ships[j][1]&&ships[i][1]>ships[j][1])
{
x.push_back({abs(ships[i][1]-ships[j][1]),i,j});
}
}
}
}
sort(x.begin(),x.end());
for(int i=0;i<x.size();i++)
{
if(sunk[x[i][1]]>=x[i][0]&&sunk[x[i][2]]>=x[i][0])
{
sunk[x[i][1]]=x[i][0];
sunk[x[i][2]]=x[i][0];
}
}
for(int i=0;i<n;i++)
{
if(sunk[i]==LLONG_MAX)
cout<<i+1<<" ";
}
return 0;
}