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. if else的执行流程

    int main(void) { int a, b; char op; float ans; scanf_s("%d%c%d",&a,&op,1,&b); ...

  2. 41、OrthoMCL和mcl软件进行基因家族分析

    转载:http://www.realbio.cn/news/124.html https://blog.csdn.net/seallama/article/details/43820763 http: ...

  3. Mac anzhuangxgboost

    2. 从Github库安装XGBoost 第一步, 克隆最新的XGBoost到本地 git clone --recursive https://github.com/dmlc/xgboost 第二步, ...

  4. jq一行一行循环读取table中的元素

    获取当前tr行号,可依据index 获取当前tr对象 获取某一tr下td的内容

  5. Part6-点亮指路灯_lesson1

    1. 2.GPIO 查阅芯片手册:GPIO 代码: 3.外设基地址初始化 打开arm核手册, 基地址为0x70000000,去搜芯片手册6410, 把这个基地址告诉处理器,通过协处理器的cp15, 转 ...

  6. 浅析C语言中assert的用法(转)

    原文地址:http://www.jb51.net/article/39685.htm 以下是对C语言中assert的使用方法进行了介绍,需要的朋友可以参考下. assert宏的原型定义在<ass ...

  7. css总结14:CSS 分页实例

    1 作用:如果你的网站有很多个页面,你就需要使用分页来为每个页面做导航. 例1 :以下实例演示了如何使用 HTML 和 CSS 来创建分页: 正常样式 <!DOCTYPE html>< ...

  8. Graphics 小记

    1.切图 drowg.DrawImage(productImg1, new System.Drawing.Rectangle(30, 30, 300, 300), new System.Drawing ...

  9. DataTable中的select()用法

    1.在DataTable中执行DataTable.Select("条件")返回DataTable // <summary> // 执行DataTable中的查询返回新的 ...

  10. C语言编程学习:链表的来源分析

    C语言是面向过程的,而C++是面向对象的 C和C++的区别: C是一个结构化语言,它的重点在于算法和数据结构.C程序的设计首要考虑的是如何通过一个过程,对输入(或环境条件)进行运算处理得到输出(或实现 ...