• BZOJ2761: [JLOI2011]不重复数字【set】【傻逼题】


    Description

    给出N个数,要求把其中重复的去掉,只保留第一次出现的数。
    例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4。

    Input

    输入第一行为正整数T,表示有T组数据。
    接下来每组数据包括两行,第一行为正整数N,表示有N个数。第二行为要去重的N个正整数。

    Output

    对于每组数据,输出一行,为去重后剩下的数字,数字之间用一个空格隔开。

    Sample Input

    2
    11
    1 2 18 3 3 19 2 3 6 5 4
    6
    1 2 3 4 5 6

    Sample Output

    1 2 18 3 19 6 5 4
    1 2 3 4 5 6

    HINT

    对于30%的数据,1 <= N <= 100,给出的数不大于100,均为非负整数;
    对于50%的数据,1 <= N <= 10000,给出的数不大于10000,均为非负整数;
    对于100%的数据,1 <= N <= 50000,给出的数在32位有符号整数范围内。
    提示:
    由于数据量很大,使用C++的同学请使用scanf和printf来进行输入输出操作,以免浪费不必要的时间。


    set傻逼题。。怎么会有这么简单的省选。。。


    //Author: dream_maker
    #include<bits/stdc++.h>
    using namespace std;
    //----------------------------------------------
    //typename
    typedef long long ll;
    //convenient for
    #define fu(a, b, c) for (int a = b; a <= c; ++a)
    #define fd(a, b, c) for (int a = b; a >= c; --a)
    #define fv(a, b) for (int a = 0; a < (signed)b.size(); ++a)
    //inf of different typename
    const int INF_of_int = 1e9;
    const ll INF_of_ll = 1e18;
    //fast read and write
    template <typename T>
    void Read(T &x) {
      bool w = 1;x = 0;
      char c = getchar();
      while (!isdigit(c) && c != '-') c = getchar();
      if (c == '-') w = 0, c = getchar();
      while (isdigit(c)) {
        x = (x<<1) + (x<<3) + c -'0';
        c = getchar();
      }
      if (!w) x = -x;
    }
    template <typename T>
    void Write(T x) {
      if (x < 0) {
        putchar('-');
        x = -x; 
      }
      if (x > 9) Write(x / 10);
      putchar(x % 10 + '0');
    }
    //----------------------------------------------
    const int N = 1e5 + 10;
    int a[N], n;
    set<int> st;
    void solve() {
      st.clear();
      Read(n);
      fu(i, 1, n) {
        Read(a[i]);
        if (i == 1 || *st.lower_bound(a[i]) != a[i]) {
          st.insert(a[i]);
          Write(a[i]);
          putchar(' ');
        }
      }
    }
    int main() {
      int T; Read(T);
      while (T--) solve();
      return 0;
    }
    
  • 相关阅读:
    支持xp风格的manifest
    XPath and TXmlDocument
    TXMLDocument use case (Delphi)
    Delphi中,除了应用程序主窗口会显示在任务栏上,其它窗口默认都不会显示在任务栏.
    Delphi下让窗口不显示在任务栏的另类方法
    拨号、断网、枚举连接名称,判断是否在线、连接方式
    [转]装逼
    这该死的数字化生活
    4根网线水晶头接法(8根只接4根即可通讯)
    关闭Delphi的RTTI
  • 原文地址:https://www.cnblogs.com/dream-maker-yk/p/9838636.html
Copyright © 2020-2023  润新知