이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define piii pair<int, pii>
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
const int dx[4]={0, 0, 1, -1};
const int dy[4]={-1, 1, 0, 0};
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n;cin>>n;
vector<int> x(n);
vector<int> y(n);
vector<int> d(n);
for(int i=0; i<n; i++){
cin>>x[i]>>y[i];
char t;cin>>t;
if(t=='N') d[i]=0;
else if(t=='S') d[i]=1;
else if(t=='E') d[i]=2;
else d[i]=3;
}
vector<piii> q;
for(int i=0; i<n; i++){
for(int j=i; j<n; j++){
if(i==j) continue;
int ti=i, tj=j;
if(x[i]==x[j]){
if(y[ti]>y[tj]) swap(ti, tj);
if(d[ti]==1&&d[tj]==0) q.pb({(y[tj]-y[ti])/2, {i, j}});
}else if(y[i]==y[j]){
if(x[ti]>x[tj]) swap(ti, tj);
if(d[ti]==2&&d[tj]==3) q.pb({(x[tj]-x[ti])/2, {i, j}});
}else{
if(abs(x[ti]-x[tj])==abs(y[ti]-y[tj])){
int ts=abs(x[ti]-x[tj]);
//cout<<i<<' '<<j<<'\n';
if((x[ti]+ts*dx[d[ti]])==(x[tj]+ts*dx[d[tj]])){
// cout<<i<<' '<<j<<'\n';
if((y[ti]+ts*dy[d[ti]])==(y[tj]+ts*dy[d[tj]])){
// cout<<i<<' '<<j<<'\n';
q.pb({abs(x[ti]-x[tj]), {i, j}});
}
}
}
}
}
}
sort(all(q));
vector<int> alive(n+1, 1e17);
for(auto [a, b]:q){
auto [x, y]=b;
//cout<<a<<' '<<x<<' '<<y<<'\n';
if((alive[x]>=a)&&(alive[y]>=a)){
alive[x]=a;
alive[y]=a;
}
}
int ans=0;
for(int i=0; i<n; i++) if(alive[i]==1e17) cout<<i+1<<'\n';
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:56:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
56 | for(auto [a, b]:q){
| ^
Main.cpp:57:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
57 | auto [x, y]=b;
| ^
Main.cpp:64:6: warning: unused variable 'ans' [-Wunused-variable]
64 | int ans=0;
| ^~~
# | 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... |