1002

标准答案在这里(链接里,下面的是错的)

#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
char table[32] = { 'A', 'B', 'C','2',
'D', 'E',  'F' , '3' ,
'G', 'H','I',  '4' ,
'J', 'K',  'L' , '5' ,
'M', 'N',  'O' , '6',
'P', 'R', 'S'  ,'7' ,
'T', 'U',  'V' , '8' ,
'W', 'X',  'Y'  ,'9' };
void sss(string &s) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '-') {
            s.erase(i, 1);
            i--;
        }
    }
    for (string::iterator e = s.begin(); e != s.end(); ++e) {
        for (int j = 0; j < 32; j++) {
            if (table[j] == *e) {
                int po = j / 4;
                *e = table[po * 4 + 3];
            }
        }
    }
};
int main() {
    int d;
    string s;
    s.resize(20);
    scanf("%d", &d);
    vector<string> ss;
    for (int w = 0; w < d; w++) {
        scanf("%s", &s[0]);
        ss.push_back(s);
    }
    vector<string>::iterator it;
    vector<string>::iterator it2;
    for (it = ss.begin(); it != ss.end(); ++it) {
        sss(*it);
        (*it).resize(8);
        (*it)[7] = '\0';
    }
    int flag = 0;
    sort(ss.begin(), ss.end());
    it = ss.begin();
    it2 = ss.begin();
    ss.push_back("|");
    while ((*it) != "|") {
        while ((*it2) == (*it)) {
            ++it2;
        }
        if ((it2 - it) > 1) {
            char b[7];
            strcpy(b, (*it).c_str());
            printf("%c%c%c-%c%c%c%c %d\n", b[0],
                b[1], b[2], b[3], b[4], b[5], b[6], (int)(it2 - it));
            flag = 1;
        }
        it = it2;
    }
    if (flag == 0) {
        printf("No duplicates.");
    }
    return 0;
};

测试数据
这个能通过
12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279
这个不能
1
888-1200
/usercode/script.sh: line 62: 13 Segmentation fault $output - < “/usercode/inputFile”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值