acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 竞赛
  • 讨论
  • 团队
登录
注册
题目详情提交记录(0)
  • 方案二

    #include<cstdio> #include<queue> #include<set> #include<cmath> using namespace std; typedef long long ll; struct node { int x, y, r; }s[102]; struct hhh { int col, id; bool f; bool operator < (const hhh &t) const { if(col == t.col)//C return id < t.id; return col > t.col; } }; priority_queue <hhh> q; set <int, greater <int> > st;//A int n, m, k; ll ans; int main() { int tmp, tt; scanf("%d %d %d", &n, &m, &k); for(int i = 1; i <= k; i ++) { scanf("%d %d %d", &s[i].x, &s[i].y, &s[i].r); } for(int i = 1; i <= n; i ++) { for(int j = 1; j <= k; j ++) { if(s[j].x + s[j].r < i || s[j].x - s[j].r > i) continue; tt = (int) sqrt(1ll * s[j].r * s[j].r - 1ll * (i - s[j].x) * (i - s[j].x)); q.push((hhh) {s[j].y - tt, j, 1}); q.push((hhh) {s[j].y + tt + 1, j, 0}); } tmp = 1; while(! q.empty()) { hhh t = q.top(); q.pop(); if(t.f == 1) { if(st.empty()) { ans += 1ll * (t.col - tmp) * k; tmp = t.col; } else if(t.id > * st.begin()) { ans += 1ll * (t.col - tmp) * (k - * st.begin()); tmp = t.col; } st.insert(t.id); } else { if(* st.begin() == t.id) { ans += 1ll * (t.col - tmp) * (k - t.id); tmp = t.col; } st.erase(t.id); } } ans += 1ll * (m - tmp + 1) * k;//B } printf("%lld\n", ans); return 0; }

    userId_undefined

    ༺ཌ༒༺ཌༀཉAC༃ༀད༻༒ད༻

    出道萌新时空双修者枚举·枚举小能手倔强青铜字符串·魔法使递归·套娃学徒
    2阅读
    0回复
    1点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页