# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
116465 | 2019-06-12T13:58:05 Z | oolimry | NLO (COCI18_nlo) | C++14 | 1020 ms | 63048 KB |
#include <bits/stdc++.h> using namespace std; int main() { //freopen("i.txt","r",stdin); ios_base::sync_with_stdio(false); cin.tie(0); long long n, m; cin >> n >> m; typedef pair<int, int> ii; static vector<int> stuff[100005]; int q; cin >> q; for(int i = 0;i < n;i++){ stuff[i].push_back(0); stuff[i].push_back(m * 1000); } for(int qq = 1;qq <= q;qq++){ long long x, y, r; cin >> y >> x >> r; x--; y--; for(int i = y - r;i <= y + r;i++){ long long dy = abs(i - y); long long dx = sqrt(r * r - dy * dy); //cout << dx << " " << dy << " " << r << "\n"; stuff[i].push_back((x - dx) * 1000 + qq); stuff[i].push_back((x + dx + 1) * 1000 + 500 + qq); } } long long ans = 0; for(int i = 0;i < n;i++){ sort(stuff[i].begin(),stuff[i].end()); set<long long> values; for(int j = 0;j < stuff[i].size();j++){ int s1 = stuff[i][j] / 1000; int s2 = stuff[i][j] % 1000; if(j != 0){ set<long long>::iterator it = values.end(); it--; long long v1 = q - *it; long long v2 = s1 - (stuff[i][j-1] / 1000); ans += v1 * v2; //cout << ans << " "; } if(s2 < 500){ values.insert(s2); } else{ values.erase(s2 - 500); } } //cout << ans << "\n"; } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2816 KB | Output is correct |
2 | Correct | 14 ms | 3328 KB | Output is correct |
3 | Correct | 11 ms | 3328 KB | Output is correct |
4 | Correct | 51 ms | 6144 KB | Output is correct |
5 | Correct | 39 ms | 5792 KB | Output is correct |
6 | Correct | 322 ms | 26768 KB | Output is correct |
7 | Correct | 116 ms | 12820 KB | Output is correct |
8 | Correct | 814 ms | 46508 KB | Output is correct |
9 | Correct | 287 ms | 20344 KB | Output is correct |
10 | Correct | 1020 ms | 63048 KB | Output is correct |