#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("popcnt")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=2e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
const ldb eps=1e-6;
const ldb PI=acos(-1.0);
const ll dir[4][2]={{0,-1},{0,1},{1,0},{-1,0}};
template<typename T>
using vvector = vector<vector<T>>;
int main() {
speed;
ll n;
cin>>n;
vector<pair<pll,ll>> p(n+1);
for (int i=1;i<=n;i++) {
char c;
cin>>p[i].F.F>>p[i].F.S>>c;
if (c=='N') p[i].S=0;
else if (c=='S') p[i].S=1;
else if (c=='E') p[i].S=2;
else p[i].S=3;
}
vector<pair<ll,pll>> coll;
for (int i=1;i<=n;i++) {
for (int j=i+1;j<=n;j++) {
if (p[i].S==p[j].S) continue;
if (dir[p[i].S][0]==0 and dir[p[j].S][0]==0) {
if (p[i].F.F!=p[j].F.F) continue;
ll d = p[j].F.S-p[i].F.S;
d/=dir[p[i].S][1];
if (d<0) continue;
coll.push_back(pair(d/2,pair(i,j)));
} else if (dir[p[i].S][1]==0 and dir[p[j].S][1]==0) {
if (p[i].F.S!=p[j].F.S) continue;
ll d = p[j].F.F-p[i].F.F;
d/=dir[p[i].S][0];
if (d<0) continue;
coll.push_back(pair(d/2,pair(i,j)));
} else if (dir[p[i].S][0]==0) {
ll t1=(p[j].F.S-p[i].F.S)/dir[p[i].S][1];
ll t2=(p[i].F.F-p[j].F.F)/dir[p[j].S][0];
if (t1<0 or t2<0 or t1!=t2) continue;
coll.push_back(pair(t1,pair(i,j)));
} else {
ll t1=(p[j].F.F-p[i].F.F)/dir[p[i].S][0];
ll t2=(p[i].F.S-p[j].F.S)/dir[p[j].S][1];
if (t1<0 or t2<0 or t1!=t2) continue;
coll.push_back(pair(t1,pair(i,j)));
}
}
}
vector<ll> ans(n+1,oo);
sort(all(coll));
for (auto [t,ij] : coll) {
cout<<t<<" "<<ij.F<<" "<<ij.S<<"\n";
if (ans[ij.F]>=t and ans[ij.S]>=t) {
ans[ij.F]=t;
ans[ij.S]=t;
}
}
for (int i=1;i<=n;i++) {
if (ans[i]==oo) cout<<i<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Protocol violation |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Protocol violation |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Protocol violation |
2 |
Halted |
0 ms |
0 KB |
- |