이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// absolutely incredible
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = a; i >= b; --i)
#define pb push_back
#define left _________left
#define right _________right
#define NAME ""
const int mod = 1e9 + 7;
void updateMax(int &u, int v){
if(v > u) u = v;
}
void updateMin(int &u, int v){
if(v < u) u = v;
}
bool maximize(int &u, int v){
if(v > u){
u = v;
return true;
}
return false;
}
bool minimize(int &u, int v){
if(v < u){
u = v;
return true;
}
return false;
}
void updateMaxll(long long &u, long long v){
if(v > u) u = v;
}
void updateMinll(long long &u, long long v){
if(v < u) u = v;
}
bool maximizell(long long &u, long long v){
if(v > u){
u = v;
return true;
}
return false;
}
bool minimizell(long long &u, long long v){
if(v < u){
u = v;
return true;
}
return false;
}
int fastPow(int a, int n){
if(n == 0) return 1;
int t = fastPow(a, n >> 1);
t = 1ll * t * t % mod;
if(n & 1) t = 1ll * t * a % mod;
return t;
}
void add(int &u, int v){
u += v;
if(u >= mod) u -= mod;
}
void sub(int &u, int v){
u -= v;
if(u < 0) u += mod;
}
const int maxN = 2e5 + 5;
struct Point{
int x, y;
char d;
int intersect(const Point &rhs)const{
if(d == rhs.d) return 0;
int temp = abs(x - rhs.x) + abs(y - rhs.y);
temp >>= 1;
if(d == 'N'){
if(rhs.d == 'E'){
if(y - temp == rhs.y && rhs.x + temp == x) return temp;
return 0;
}
if(rhs.d == 'S'){
if(y - temp == rhs.y + temp && x == rhs.x) return temp;
return 0;
}
if(y - temp == rhs.y && x == rhs.x - temp) return temp;
return 0;
}
if(d == 'E'){
if(rhs.d == 'N'){
if(x + temp == rhs.x && rhs.y - temp == y) return temp;
return 0;
}
if(rhs.d == 'W'){
if(x + temp == rhs.x - temp && y == rhs.y) return temp;
return 0;
}
if(x + temp == rhs.x && rhs.y + temp == y) return temp;
return 0;
}
if(d == 'S'){
if(rhs.d == 'N'){
if(y + temp == rhs.y - temp && x == rhs.x) return temp;
return 0;
}
if(rhs.d == 'E'){
if(y + temp == rhs.y && rhs.x + temp == x) return temp;
return 0;
}
if(y + temp == rhs.y && rhs.x - temp == x) return temp;
return 0;
}
if(rhs.d == 'N'){
if(x - temp == rhs.x && rhs.y - temp == y) return temp;
return 0;
}
if(rhs.d == 'E'){
if(x - temp == rhs.x + temp && y == rhs.y) return temp;
return 0;
}
if(x - temp == rhs.x && rhs.y + temp == y) return temp;
return 0;
}
}p[maxN];
const int INF = INT_MAX;
int N;
namespace subtask12345{
bool check(){
return N <= 5000;
}
const int maxT = 12497500 + 1;
pair<int, pair<int, int>> t[maxT];
int del[maxN];
void solve(){
int cnt = 0;
// cout << p[3].intersect(p[4]) << '\n';
// cout << abs(p[3].x - p[4].x) + abs(p[3].y - p[4].y) << '\n';
FOR(i, 1, N){
FOR(j, i + 1, N){
int k = p[i].intersect(p[j]);
if(k > 0)t[++cnt] = {k, {i, j}};
}
}
sort(t + 1, t + 1 + cnt);
// cout << cnt << "\n";
// cout << p[2].intersect(p[6]) << '\n';
FOR(i, 1, N)del[i] = INF;
// cout << p[1].intersect(p[5]) << "\n";
FOR(i, 1, cnt){
int k = t[i].first;
int pi = t[i].second.first;
int pj = t[i].second.second;
if(del[pi] < k || del[pj] < k)continue;
del[pi] = del[pj] = k;
// cout << pi << ' ' << pj << ' ' << k << "\n";
}
// FOR(i, 1, N){
// cout << i << ' ' << del[i] << "\n";
// }
FOR(i, 1, N){
if(del[i] == INF)cout << i << "\n";
}
}
}
void solve(){
cin >> N;
int x, y;
char d;
FOR(i, 1, N){
cin >> x >> y >> d;
p[i] = {x, y, d};
}
if(subtask12345 :: check()) return subtask12345 :: solve();
}
int main(){
if(fopen(NAME".inp", "r")){
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:175:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
175 | freopen(NAME".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:176:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
176 | freopen(NAME".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |