| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:TimeLimited。逐字节输入,维护输出队列,然后对队列快排。讲真,这题测试数据是针对快排的吗??在下不才,感觉理论上已经是最优解了In Reply To:TimeLimited。逐字节输入,维护输出队列,然后对队列快排。讲真,这题测试数据是针对快排的吗??在下不才,感觉理论上已经是最优解了 Posted by:Sunshone at 2018-07-18 20:45:50 > #include<iostream>
> #include<string.h>
> #include<algorithm>
> using namespace std;
> #define MAXS 10000000
> int n, leno, flag, book[MAXS] = { 0 }, outlist[1000010] = { 0 }, t[500] = { 0 };
> char line[20] = { 0 }, ch;
> int out[10];
> void Input()
> {
> int i, Tel, counter;
> for (i = 0; i <= 9; i++) t[i+48] = i;
> t['A'] = t['B'] = t['C'] = 2;
> t['D'] = t['E'] = t['F'] = 3;
> t['G'] = t['H'] = t['I'] = 4;
> t['J'] = t['K'] = t['L'] = 5;
> t['M'] = t['N'] = t['O'] = 6;
> t['P'] = t['R'] = t['S'] = 7;
> t['T'] = t['U'] = t['V'] = 8;
> t['W'] = t['X'] = t['Y'] = 9;
> cin >> n;
> flag = leno = 0;
> for (i = 0; i < n; i++)
> {
> counter = 0;
> for (counter = Tel = 0; counter < 7; counter++)
> {
> cin >> ch;
> if (ch == '-' || ch == 'Q' || ch == 'Z'){
> counter--;
> continue;
> }
> Tel = Tel * 10 + t[ch];
> }
> if (Tel > MAXS){ // 异常值保护模块
> printf("ALERT\n");
> system("pause");
> }
> flag += (book[Tel] == 0);
> if (book[Tel] == 1) outlist[leno++] = Tel; // book[]: Tel 的 frequency,outlist[]堆栈,有值
> book[Tel]++;
> }
> }
> void FormOut(int a)
> {
> int i;
> memset(out, 0, sizeof(out));
> for (i = 1000000; i >= 10000; i /= 10)
> printf("%d", (a % (i * 10)) / i);
> printf("-");
> for(;i > 1; i/=10)
> printf("%d", (a % (i * 10)) / i);
> printf("%d %d\n", a%10, book[a]);
> }
> void Output()
> {
> int i;
> if (flag == n){
> printf("No duplicates.\n");
> return;
> }
> for (i = 0; i < leno; i++)
> FormOut(outlist[i]);
> //printf("%d-%d %d\n", outlist[i]/10000, outlist[i]%10000, book[outlist[i]]);
> }
> void test()
> {
> int i;
> for (i = 0; i < leno; i++)
> printf("%d# MultiplePhoneNum is %d, frequence is %d\n", i, outlist[i], book[outlist[i]]);
> printf("leno = %d\n", leno);
> system("pause");
> }
> int main()
> {
> Input();
> //qsort(outlist, leno, sizeof(outlist[0]), cmp);
> sort(outlist, outlist + leno);
> //test();
>
> Output();
> //system("pause");
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator