http://acm.hdu.edu.cn/showproblem.php?pid=4022

被轰炸的地点直接向飞行员报告:“我是你的攻击目标!”
...报告完毕

/*390ms,5624KB*/

const int mx = int(1e5) + 5;

pair<int, int> point[mx];
map<int, int> time_x, time_y;
int ans[mx];

int main()
{
    int n, m, i, u, v;
    while (SII(n, m), n || m)
    {
        time_x.clear(), time_y.clear();
        for (i = 0; i < n; ++i) SII(point[i].first, point[i].second);
        for (i = 1; i <= m; ++i)
        {
            SII(u, v);
            if (u) {if (!time_y[v]) time_y[v] = i;} /// 记录轰炸的时间编号
            else {if (!time_x[v]) time_x[v] = i;}
        }
        memset(ans, 0, sizeof(ans));
        for (i = 0; i < n; ++i)
        {
            u = time_x[point[i].first];
            v = time_y[point[i].second]; /// 获取时间编号
            if (!u && !v) continue;
            else if (!u) ++ans[v];
            else if (!v) ++ans[u];
            else ++ans[min(u, v)];
        }
        for (i = 1; i <= m; ++i) PI(ans[i]);
        putchar(10);
    }
    return 0;
}

Comments

comments powered by Disqus