1 条题解

  • 0
    @ 2025-3-7 11:49:56

    超级抽象的卡时间简单题,快读快写都要加,map映射时要用map<int, int>,用string直接T;
    双倍经验: https://www.luogu.com.cn/problem/UVA755

    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    #include <vector>
    #include <map>
    #include <queue>
    #include <algorithm>
    #include <math.h>
    #include <cstdio>
    using namespace std;
    
    int t, n;
    map<int, int> cnt;
    string ln;
    
    int main()
    {
    	t = 1;
    	while (t)
    	{
    		cin >> n;
    		for (int i = 1; i <= n; i += 1)
    		{
    			cin >> ln;
    			int len = ln.length(), val = 0;
    			for (int j = 0; j <= len - 1; j += 1)
    			{
    				if (ln[j] >= 'A' and ln[j] <= 'Z' or ln[j] >= '0' and ln[j] <= '9')
    				{
    					val *= 10;
    					if (ln[j] == '0') val += 0;
    					if (ln[j] == '1') val += 1;
    					if (ln[j] >= 'A' && ln[j] <= 'C' || ln[j] == '2') val += 2;
    					if (ln[j] >= 'D' && ln[j] <= 'F' || ln[j] == '3') val += 3;
    					if (ln[j] >= 'G' && ln[j] <= 'I' || ln[j] == '4') val += 4;
    					if (ln[j] >= 'J' && ln[j] <= 'L' || ln[j] == '5') val += 5;
    					if (ln[j] >= 'M' && ln[j] <= 'O' || ln[j] == '6') val += 6;
    					if (ln[j] >= 'P' && ln[j] <= 'S' || ln[j] == '7') val += 7;
    					if (ln[j] >= 'T' && ln[j] <= 'V' || ln[j] == '8') val += 8;
    					if (ln[j] >= 'W' && ln[j] <= 'Y' || ln[j] == '9') val += 9;
    				}
    			}
    			cnt[val] += 1;
    		}
    		bool flag = 0;
    		map<int, int>::iterator iter;
    		for ( iter = cnt.begin(); iter != cnt.end(); ++iter) if (iter->second >= 2) { printf("%03d-%04d %d\n", iter->first / 10000, iter->first % 10000, iter->second); flag = 1; }
    		if (flag == 0) cout << "No duplicates." << endl;
    		t -= 1;
    	}
    }
    
    • 1

    信息

    ID
    3
    时间
    1000ms
    内存
    256MiB
    难度
    3
    标签
    递交数
    11
    已通过
    2
    上传者