| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 446037 | prvocislo | Dominance (CEOI08_dominance) | C++17 | 18 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct obdl { int r1, c1, r2, c2; };
const ll inf = 1e10;
ll count(ll r1, ll c1, ll r2, ll c2) // spocita pocet platnych bodov, vratane
{
r1 += inf, c1 += inf, r2 += inf, c2 += inf;
ll even_rows = r2/2 - (r1-1)/2, odd_rows = r2 - r1 + 1 - even_rows;
ll even_columns = c2/2 - (c1-1)/2, odd_columns = c2 - c1 + 1 - even_columns;
return even_rows * even_columns + odd_rows * odd_columns;
}
struct udalost { ll x, y1, y2; int d; };
bool cmp(const udalost &a, const udalost &b) { return a.x < b.x; }
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int w, h, n;
cin >> w >> h >> n;
vector<udalost> e;
set<int> sy;
for (int i = 0, x, y, d; i < n; i++)
{
char c;
cin >> c >> x >> y >> d;
int delta = c == 'W' ? 1 : -1;
e.push_back({x-y-d, x+y-d, x+y+d+1, delta});
e.push_back({x-y+d+1, x+y-d, x+y+d+1, -delta});
}
for (udalost i : e) sy.insert(i.y1), sy.insert(i.y2);
vector<int> vy(sy.begin(), sy.end()), sum(vy.size(), 0);
sort(e.begin(), e.end(), cmp);
ll cntw = 0, cntb = 0;
//for (int j = 0; j < vy.size(); j++) cout << vy[j] << " ";
//cout << endl << "============" << endl;
for (int i = 0; i < e.size()-1; i++)
{
for (int j = 0; j < vy.size(); j++) if (e[i].y1 <= vy[j] && vy[j] < e[i].y2)
sum[j] += e[i].d;
for (int j = 0; j < vy.size() - 1; j++)
{
ll ok = count(e[i].x, vy[j], e[i+1].x-1, vy[j+1]-1);
if (sum[j] > 0) cntw += ok;
if (sum[j] < 0) cntb += ok;
}
//for (int j = 0; j < vy.size(); j++) cout << sum[j] << " ";
//cout << "| " << e[i].x << endl;
}
cout << cntw << " " << cntb << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
