# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1103683 | TVSown | Naval battle (CEOI24_battle) | C++17 | 256 ms | 27476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///***LTT***///
/// ->NHAT QUOC GIA<- ///
#include<bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
//#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
using namespace std;
vector <int> lg2;
//void MAKE_LOG_ARR(int n){
// lg2.resize(n + 3);
// for (int i = 1;i <= n;++i){
// lg2[i] = __lg(i);
// }
//}
const long long oo = 1e9+7;
const int N = 2 * 1e5 + 10;
int n;
int x[N], y[N];
char type[N];
pair <int, pair <int ,int>> a[2500004];
int die[N];
long long giao(int a, int b){
if (type[a] == type[b]) return -1;
if (type[a] > type[b])swap(a,b);
if (type[a] == 'E' and type[b] == 'S'){
int deltax = x[b] - x[a];
int deltay = y[a] - y[b];
if (deltax > 0 and deltax == deltay) return deltax; else return -1;
}
if (type[a] == 'E' and type[b] == 'N'){
int deltax = x[b] - x[a];
int deltay = y[b] - y[a];
if (deltax > 0 and deltax == deltay) return deltax; else return -1;
}
if (type[a] == 'E' and type[b] == 'W'){
int deltax = x[b] - x[a];
deltax /= 2;
if (deltax > 0 and y[b] == y[a]) return deltax; else return -1;
}
if (type[a] == 'N' and type[b] == 'S'){
int deltay = y[a] - y[b];
deltay /= 2;
if (deltay > 0 and x[a] == x[b]) return deltay; else return -1;
}
if (type[a] == 'N' and type[b] == 'W'){
int deltay = y[a] - y[b];
int deltax = x[b] - x[a];
if (deltay > 0 and deltax == deltay) return deltax; else return -1;
}
if (type[a] == 'S' and type[b] == 'W'){
int deltay = y[b] - y[a];
int deltax = x[b] - x[a];
if (deltay > 0 and deltax == deltay) return deltax; else return -1;
}
}
void solve(){
cin >> n;
for (int i = 1;i <= n;++i){
cin >> x[i] >> y[i] >> type[i];
}
assert(n <= 5000);
int pt = 0;
for (int i = 1;i <= n;++i){
for (int j = i + 1;j <= n;++j){
int z = giao(i,j);
if (z != -1){
a[++pt] = {z,{i,j}};
}
}
}
for (int i= 1;i <= n;++i) die[i] = oo + 100;
sort(a + 1,a + pt + 1);
for (int i = 1;i <= pt;++i){
int u = a[i].S.F;
int v = a[i].S.S;
int ti = a[i].F;
if (die[u] < ti or die[v] < ti) continue;
die[u] = ti;
die[v] = ti;
}
bool found = false;
for (int i = 1;i <= n;++i){
if (die[i] == oo + 100){
cout << i <<"\n";
found = true;
}
}
// if (!found) cout << 0;
return;
}
int main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
if (fopen("ltt.inp", "r")){
freopen("ltt.inp", "r", stdin);
freopen("ltt.out", "w", stdout);
}
// int t;
// cin >> t;
// while(t--){
solve();
// }
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |