C - ID


Time limit : 2sec / Memory limit : 1024MB

Score: 300 points

Problem Statement

In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.

City i is established in year Yi and belongs to Prefecture Pi.

You can assume that there are no multiple cities that are established in the same year.

It is decided to allocate a 12-digit ID number to each city.

If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is Pi, and the last six digits of the ID number is x.

Here, if Pi or x (or both) has less than six digits, zeros are added to the left until it has six digits.

Find the ID numbers for all the cities.

Note that there can be a prefecture with no cities.

Constraints

  • 1≤N≤105
  • 1≤M≤105
  • 1≤PiN
  • 1≤Yi≤109
  • Yi are all different.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
P1 Y1
:
PM YM

Output

Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2).


Sample Input 1

Copy
2 3
1 32
2 63
1 12

Sample Output 1

Copy
000001000002
000002000001
000001000001
  • As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.
  • As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.
  • As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.

Sample Input 2

Copy
2 3
2 55
2 77
2 99

Sample Output 2

Copy
000002000001
000002000002
000002000003 高级点的结构体排序,主要难点是判断每个区间的数字排序
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
//#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF (1<<31)-1;
#define mem(a) (memset(a,0,sizeof(a)))
struct P{
int x,y;
}H[];
vector<int>G[];
int POS(int k,int value){
int mid;
int left = ;
int len = G[k].size();
int right = len - ;
//cout<<" "<<k<<"A"<<value<<endl;
while(left <= right){ // 确保中点靠近区间的起点
mid = left + (right-left)/;
//cout<<mid<<endl;
//cout<<"mid= "<<mid<<" "<<left<<" "<<right<<endl;
// 如果找到则返回
if(G[k][mid] == value) return mid;
// 将中点赋给终点
else if(G[k][mid] > value) right = mid;
// 将中点加一赋给起点
else left = mid + ;
}
return -;
}
set<int>::iterator it;
int main()
{
set<int>s;
int N,M;
int x,y;
cin>>N>>M;
for(int i=;i<=M;i++){
cin>>x>>y;
H[i].x = x;
H[i].y = y;
G[x].push_back(y);
s.insert(x);
}
for(int i=;i<=N;i++){
sort(G[i].begin(),G[i].end());
} for(int i=;i<=M;i++){
cout<<setw()<<setfill('')<<H[i].x;
cout<<setw()<<setfill('')<<POS(H[i].x,H[i].y)+<<endl;
}
return ;
}

AtCoder Beginner Contest 113 C的更多相关文章

  1. AtCoder Beginner Contest 113 D Number of Amidakuji

    Number of Amidakuji 思路:dp dp[i][j]表示经过(i, j) 这个点的方案数 然后一层一层地转移, 对于某一层, 用二进制枚举这一层的连接情况, 判断连接是否符合题意, 然 ...

  2. AtCoder Beginner Contest 113 B

    B - Palace Time limit : 2sec / Memory limit : 1024MB Score: 200 points Problem Statement A country d ...

  3. AtCoder Beginner Contest 113 A

    A - Discount Fare Time limit : 2sec / Memory limit : 1024MB Score: 100 points Problem Statement Ther ...

  4. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  5. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  6. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  7. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  8. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  9. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

随机推荐

  1. 更改windows服务的配置文件(app.config)必须重启服务才能生效吗?

    这个问题是前一阶段写windows服务碰到的.本来在写获取配置文件的某个配置的值的时候,通常我都是写类似下面的这么一个静态方法来获取: 1: /// <summary> 2: /// 获取 ...

  2. CentOS 安装mongodb3.0 二进制包

    1.下载mongodb因为64位系统CentOS,所以下载64位的安装包: wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0 ...

  3. Django--model模型绑定_数据库操作

    1.创建model类 app01/models.py 1 2 3 4 5 6 7 from django.db import models   # Create your models here. c ...

  4. python pipelines 用法

    http://zacstewart.com/2014/08/05/pipelines-of-featureunions-of-pipelines.html http://blog.csdn.net/m ...

  5. CF 961G Partitions

    推不动式子 我们考虑每一个$w_i$对答案的贡献,因为题目中定义集合的价值为$W(S) = \left | S \right |\sum_{x \in S}w_x$,这个系数$\left | S \r ...

  6. Mybatis_映射文件配置

    获取自增主键的值 若数据库支持自动生成主键的字段(比如 MySQL 和 SQL Server),则可以设置 useGeneratedKeys=”true”,然后再把 keyProperty 设置到目标 ...

  7. App测试从入门到精通之性能测试

    好了,上节我们介绍了关于APP测试的功能测试方面一些细节.这一篇我们来介绍一下,关于APP测试过程中的性能测试参考要点,我们需要思考的如下: 响应时间 1.APP安装卸载的响应时间 2.APP各种功能 ...

  8. 《Wonderland: A Novel Abstraction-Based Out-Of-Core Graph Processing System》章明星

    在2018年3月28日于美国弗吉尼亚州威廉斯堡结束的ACM ASPLOS 2018会议上,计算机系高性能所师生发表了两篇长文.一篇是我系博士生章明星为第一作者,导师武永卫为通讯作者的“Wonderla ...

  9. 编写高质量代码改善C#程序的157个建议——建议34:为泛型参数设定约束

    建议34:为泛型参数设定约束 “约束”这个词可能会引起歧义,有些人肯能认为对泛型参数设定约束是限制参数的使用,实际情况正好相反.没有“约束”的泛型参数作用很有限,倒是“约束”让泛型参数具有了更多的行为 ...

  10. Maven类包冲突终极三大解决技巧 mvn dependency:tree

    Maven对于新手来说是<步步惊心>,因为它包罗万象,博大精深,因为当你初来乍到时,你就像一个进入森林的陌生访客一样迷茫. Maven对于老手来说是<真爱配方>,因为它无所不能 ...