#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,-O3")
#define F first
#define S second
#define pb push_back
#define N +100500
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
int xr[N], xl[N], yl[N], yr[N], lx, ly, i, j, n, ans[N], sf[N], sf1[N], sf2[N], sf3[N];
int main()
{
srand(time(0));
ios_base::sync_with_stdio(0);
iostream::sync_with_stdio(0);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
// in("input.txt");
// out("output.txt");
cin >> n;
for (i = 1; i <= n; i++)
{
cin >> xl[i] >> yl[i] >> lx >> ly;
xr[i] = xl[i] + lx;
yr[i] = yl[i] + ly;
}
ans[n] = 1;
sf[n] = xr[n];
sf1[n] = yr[n];
sf2[n] = xl[n];
sf3[n] = yl[n];
for (i = n - 1; i >= 1; i--) sf[i] = max(sf[i + 1], xr[i]), sf2[i] = min(sf2[i + 1], xl[i]), sf1[i] = max(sf1[i + 1], yr[i]), sf3[i] = min(sf3[i + 1], yl[i]);
for (i = 1; i <= n; i++)
{
if (min(xr[i], sf[i + 1]) <= max(sf2[i + 1], xl[i])) {ans[i] = 1;continue;}
if (min(yr[i], sf1[i + 1]) <= max(sf3[i + 1], yl[i])) {ans[i] = 1;continue;}
for (j = i + 1; j <= n; j++)
{
if (min(xr[i], xr[j]) > max(xl[i], xl[j]) &&
min(yr[i], yr[j]) > max(yl[i], yl[j])) {ans[i] = 0;break;}
ans[i] = 1;
}
}
for (i = 1; i <= n; i++) cout << (ans[i] ? "DA" : "NE") << el;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
768 KB |
Output is correct |
2 |
Correct |
37 ms |
880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
1272 KB |
Output is correct |
2 |
Correct |
1241 ms |
3620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
1920 KB |
Output is correct |
2 |
Correct |
1941 ms |
4352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
126 ms |
2552 KB |
Output is correct |
2 |
Correct |
1367 ms |
3844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
713 ms |
4020 KB |
Output is correct |
2 |
Correct |
1999 ms |
4792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
510 ms |
3960 KB |
Output is correct |
2 |
Correct |
1538 ms |
4244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1613 ms |
3872 KB |
Output is correct |
2 |
Correct |
111 ms |
4984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3361 ms |
5524 KB |
Output is correct |
2 |
Correct |
276 ms |
4048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2200 ms |
5548 KB |
Output is correct |
2 |
Correct |
3223 ms |
6008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2274 ms |
6396 KB |
Output is correct |
2 |
Execution timed out |
4098 ms |
6648 KB |
Time limit exceeded |