# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1103683 | TVSown | Naval battle (CEOI24_battle) | C++17 | 256 ms | 27476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///***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;
}
Compilation message (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... |