16级线上比赛++(2017/04/02)

发布时间:2020-03-12 19:34:54
贴主:BUS18087赵晨
热度:2
正在讨论:P2178 - 小猫爬山 题目传送门

BUS18087赵晨 2020-03-12

1

(0)

只会水题的菜鸡 2020-03-16

            我的想法就是暴力查找(wtcl)#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    
    int n;
    cin >> n;
    while (n--)
    {
        int m;
        cin >> m;
        string* a = new string[m];
       
        for (int i = 0; i < m; i++)
        {
            cin >> a[i];
           
        }
        cout << a[0];
        for (int i = 1; i < m; i++)
        {
            bool flag = false;
            for (int j = 0; j < i; j++)
            {
                if (a[j].substr(0, 3) == a[i].substr(0, 3))
                {
                    break;
                }
                if (j == i - 1)
                {
                    flag = true;
                }
            }
            if (flag)
            {
                cout << " " << a[i];
            }
        }
        cout << endl;
    }
    return 0;
}


        

(0)

Copyright 2016 - 2024 XUJC ACM Team
闽ICP备2020022076号-1