AtCoder Beginner Contest 113 C
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≤Pi≤N
- 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
2 3
1 32
2 63
1 12
Sample Output 1
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
2 3
2 55
2 77
2 99
Sample Output 2
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的更多相关文章
- AtCoder Beginner Contest 113 D Number of Amidakuji
Number of Amidakuji 思路:dp dp[i][j]表示经过(i, j) 这个点的方案数 然后一层一层地转移, 对于某一层, 用二进制枚举这一层的连接情况, 判断连接是否符合题意, 然 ...
- AtCoder Beginner Contest 113 B
B - Palace Time limit : 2sec / Memory limit : 1024MB Score: 200 points Problem Statement A country d ...
- AtCoder Beginner Contest 113 A
A - Discount Fare Time limit : 2sec / Memory limit : 1024MB Score: 100 points Problem Statement Ther ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 052
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 136
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
随机推荐
- 1-在eclipse里面配置python(最详细)
最近有时间打算学下python,打算学当然是得先搞好开发工具,网上搜一波,发现许多ide,居然可以在eclipse下写python,由于最近一直在搞java,所以已经装了eclipse,所以打算就在e ...
- Process management of windows
igfxem.exe进程是正常的进程.是intel家的核显驱动类的进程.核显即"核芯显卡",是指GPU部分它是与CPU建立在同一内核芯片上,两者完全融合的芯片."核芯显卡 ...
- 10.Execution failed with exit status: 3
错误信息: insert overwrite table t_mobile_mid_use_p_tmp4_rcf select '201411' as month_id, a.prov_id, a.c ...
- xgboost 调参 !
https://jessesw.com/XG-Boost/ http://blog.csdn.net/u010414589/article/details/51153310
- Logistic Regression 用于预测马是否生病
1.利用Logistic regression 进行分类的主要思想 根据现有数据对分类边界线建立回归公式,即寻找最佳拟合参数集,然后进行分类. 2.利用梯度下降找出最佳拟合参数 3.代码实现 # -* ...
- php变量数据类型
整型:可以用十进制.八进制.十六进制指定.十进制就是日常使用的数字:八进制,数字前必须加上“0”(这个0是阿拉伯数字0,可不是英文字母“欧”哦):十六进制,数字前必须加“0x” (这个0也是阿拉伯数字 ...
- javascript总结8:JavaScript 类型转换
1 JavaScript 数据类型转换 1.1 数字类型转字符串 n1 = 10;var n2 =String(n1); 或者 var n3 = n1.toString(n1); 1.2 字符串转数字 ...
- POJ3295 Tautology(栈+枚举)
Description WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some ...
- 图的遍历——DFS
原创 图的遍历有DFS和BFS两种,现选用DFS遍历图. 存储图用邻接矩阵,图有v个顶点,e条边,邻接矩阵就是一个VxV的矩阵: 若顶点1和顶点5之间有连线,则矩阵元素[1,5]置1,若是无向图[5, ...
- c# 实现点击下载功能
转自百度知道 private void DownLoad(string strName, string strPath) { string fileName = strName;//客户端保存的文件名 ...