2017ACM/ICPC广西邀请赛 Color it
Color it
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s):
0
especially messy color paintings. Now Little B is painting. To prevent him from
drawing messy painting, Little D asks you to write a program to maintain
following operations. The specific format of these operations is as
follows.
0
: clear all the points.
1
x
y
c
: add a point which color is c
at point (x,y)
.
2
x
y1
y2
: count how many different colors in the square (1,y1)
and (x,y2)
. That is to say, if there is a point (a,b)
colored c
, that 1≤a≤x
and y1
≤b≤y
2
, then the color c
should be counted.
3
: exit.
Each line
contains a operation. It may be '0', '1 x y c' ( 1≤x,y≤106
,0≤c≤50
), '2 x y1 y2' (1≤x,y1
,y
2
≤10
6
) or '3'.
x,y,c,y1,y2
are all integers.
Assume the last operation is 3 and it appears only
once.
There are at most 150000
continuous operations of operation 1 and operation 2.
There are at most
10
operation 0.
answer .
1 1000000 1000000 50
1 1000000 999999 0
1 1000000 999999 0
1 1000000 1000000 49
2 1000000 1000000 1000000
2 1000000 1 1000000
0
1 1 1 1
2 1 1 2
1 1 2 2
2 1 1 2
1 2 2 2
2 1 1 2
1 2 1 3
2 2 1 2
2 10 1 2
2 10 2 2
0
1 1 1 1
2 1 1 1
1 1 2 1
2 1 1 2
1 2 2 1
2 1 1 2
1 2 1 1
2 2 1 2
2 10 1 2
2 10 2 2
3
3
1
2
2
3
3
1
1
1
1
1
1
1
//但是 我的代码简单
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
using namespace std; struct Node
{
int x;
int y;
} node;
vector<Node>v[];
int main()
{
int k,c;
int x2,y1,y2;
while()
{
scanf("%d",&k);
if(k==)break;
if(k==)
{
for(int i=; i<; ++i)
v[i].clear();
}
else if(k==)
{
scanf("%d%d%d",&node.x,&node.y,&c);
v[c].push_back(node);
}
else
{
int ans=;
scanf("%d%d%d",&x2,&y1,&y2);
for(int i=; i<=; ++i)
{
for(int j=; j<v[i].size(); ++j)
{
int xx=v[i][j].x;
int yy=v[i][j].y;
if(xx<=x2&&yy<=y2&&yy>=y1)
{
ans++;
break;
}
}
}
printf("%d\n",ans);
}
}
return ;
}
//欢迎喜欢算法 IT的dalao加1345411028 带我飞
2017ACM/ICPC广西邀请赛 Color it的更多相关文章
- 2017ACM/ICPC广西邀请赛-重现赛
HDU 6188 Duizi and Shunzi 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 思路: 签到题,以前写的. 实现代码: #inc ...
- 2017ACM/ICPC广西邀请赛-重现赛 1007.Duizi and Shunzi
Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai( ...
- 2017ACM/ICPC广西邀请赛-重现赛 1010.Query on A Tree
Problem Description Monkey A lives on a tree, he always plays on this tree. One day, monkey A learne ...
- 2017ACM/ICPC广西邀请赛-重现赛 1004.Covering
Problem Description Bob's school has a big playground, boys and girls always play games here after s ...
- HDU 6191 2017ACM/ICPC广西邀请赛 J Query on A Tree 可持久化01字典树+dfs序
题意 给一颗\(n\)个节点的带点权的树,以\(1\)为根节点,\(q\)次询问,每次询问给出2个数\(u\),\(x\),求\(u\)的子树中的点上的值与\(x\)异或的值最大为多少 分析 先dfs ...
- 2017ACM/ICPC广西邀请赛-重现赛 1001 A Math Problem
2017-08-31 16:48:00 writer:pprp 这个题比较容易,我用的是快速幂 写了一次就过了 题目如下: A Math Problem Time Limit: 2000/1000 M ...
- 2017ACM/ICPC广西邀请赛-重现赛1005 CS course
2017-08-31 16:19:30 writer:pprp 这道题快要卡死我了,队友已经告诉我思路了,但是做题速度很缓慢,很费力,想必是因为之前 的训练都是面向题解编程的缘故吧,以后不能这样了,另 ...
- 2017ACM/ICPC广西邀请赛
A.A Math Problem #include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll ...
- 2017ACM/ICPC广西邀请赛 Duizi and Shunzi
题意:就是一个集合分开,有两种区分 对子:两个相同数字,顺子:连续三个不同数字,问最多分多少个 解法:贪心,如果当前数字不构成顺子就取对子 /2,如果可以取顺子,那么先取顺子再取对子 #include ...
随机推荐
- IDEA 中 Git Commit message 编写
IDEA安装插件 Git Commit Template 1. HeaderHeader的部分只有一行,包括三个字段: type(必需), scope(可选), subject(必需) 对应到idea ...
- PHP memcache 环形队列
<?php /** * PHP memcache 环形队列类 * 因业务需要只保留的队列中的Pop和Push,修改过期时间为0即永久 */ class MQueue { pub ...
- python中的raw string的使用
背景 我们经常需要使用raw string,在应用过程中,比如要使字符串中带一些转义字符或者其他的一些符号,我们就需要保持我们的字符成为raw string. 实例 输入 s = 'fadfafa\n ...
- Entity 类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误
查看网上的资料,应该是报错的实体类com.example.domain.p.User中没有添加加主键的注解@Id,这个是必须的.但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢? 后来检查 ...
- Spring Data JPA:关联映射操作
1.一对一的关系关联 需求:用户和角色一对一关联 package com.example.jpa.pojo; import javax.persistence.*; @Entity @Table(na ...
- Reincarnation HDU - 4622 (后缀自动机)
Reincarnation \[ Time Limit: 3000 ms\quad Memory Limit: 65536 kB \] 题意 给出一个字符串 \(S\),然后给出 \(m\) 次查询, ...
- ent 基本使用十六 聚合
ent 提供了聚合处理 一个group by + 聚合的处理(age以及name字段) package main import ( "context" "< ...
- vue使用插件的流程
1.引入vue 2.引入插件 3.通过vue.use()调用 例子:使用router插件 import Vue from "vue"; import VueRouter from ...
- 如何让SublimeText3更好用
有关如何让Sublime Text3更好用 序言 某天在网上看到对于SublimeText3的介绍:一款插件功能强大的编辑器 ... 如果没有插件的话根本就是个稍微有点快捷键.配色喜人的普通编辑器,跟 ...
- Internet地址结构
IP地址结构及分类寻址 IP地址 = <网络号> + <主机号> ------------IPv4(32bit)点分四组表示法: 192.168.31.1 ...