이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
using namespace std;
#include <bits/stdc++.h>
#define int long long
int srt(array<int,3> a, array<int,3> b)
{
return a[1] < b[1];
}
int srt2(array<int,3> a,array<int,3> b)
{
return a[1] + a[0]< b[0] + b[1];
}
int32_t main()
{
int t;
cin>>t;
vector<array<int,3>> n,e,w,s;
vector<int> ans;
for(int i=0;i<t;i++)
{
int a,b;
char c;
cin>>a>>b>>c;
if(c=='N')
{
n.push_back({a,b,1+i});
}
if(c=='E')
{
e.push_back({a,b,1+i});
}
if(c=='W')
{
w.push_back({a,b,1+i});
}
if(c=='S')
{
s.push_back({a,b,1+i});
}
}
sort(e.begin(),e.end(),srt);
sort(s.begin(),s.end());
sort(e.begin(),e.end(),srt2);
sort(s.begin(),s.end(),srt2);
/*for(int i=0;i<e.size();i++)
{
cout<<e[i][0]<<" "<<e[i][1]<<endl;
}
cout<<endl<<endl;
for(int i=0;i<s.size();i++)
{
cout<<s[i][0]<<" "<<s[i][1]<<endl;
}*/
int i=0;
int j=0;
while(i<e.size()&&j<s.size())
{
if(e[i][0]+e[i][1]==s[j][0]+s[j][1])
{
ans.push_back(e[i][2]);
ans.push_back(s[j][2]);
i++;
j++;
}
if(e[i][0]+e[i][1]<s[j][0]+s[j][1])
{
i++;
}
if(e[i][0]+e[i][1]>s[i][0]+s[i][1])
{
j++;
}
}
sort(ans.begin(),ans.end());
ans.push_back(0);
for(int i=0;i<t;i++)
{
/* int l=0,r=ans.size()-1;
int flag=0;
while(l+1<r)
{
int mid=(r+l)/2;
if(ans[mid]==i+1)
flag=1;
else if(ans[mid]>i+1)
r=mid;
else
l=mid;
}*/
auto it=lower_bound(ans.begin(),ans.end(),i+1);
if(*it!=1+i)
cout<<i+1<<" ";
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int32_t main()':
Main.cpp:58:12: 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]
58 | while(i<e.size()&&j<s.size())
| ~^~~~~~~~~
Main.cpp:58:24: 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]
58 | while(i<e.size()&&j<s.size())
| ~^~~~~~~~~
# | 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... |