이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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')
{
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')
{
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;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int32_t main()':
Main.cpp:89:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | for(int i=0;i<x.size();i++)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |