• UVa 10887 Concatenation of Languages


    方法:hash

    用一个unordered_set 存所有可能的string

    code:

      1 #include <cstdio>
      2 #include <cstring>
      3 #include <algorithm>
      4 #include <iostream>
      5 #include <string>
      6 #include <vector>
      7 #include <stack>
      8 #include <bitset>
      9 #include <cstdlib>
     10 #include <cmath>
     11 #include <set>
     12 #include <list>
     13 #include <deque>
     14 #include <map>
     15 #include <queue>
     16 #include <fstream>
     17 #include <cassert>
     18 #include <unordered_map>
     19 #include <unordered_set>
     20 #include <cmath>
     21 #include <sstream>
     22 #include <time.h>
     23 #include <complex>
     24 #include <iomanip>
     25 #define Max(a,b) ((a)>(b)?(a):(b))
     26 #define Min(a,b) ((a)<(b)?(a):(b))
     27 #define FOR(a,b,c) for (ll (a)=(b);(a)<(c);++(a))
     28 #define FORN(a,b,c) for (ll (a)=(b);(a)<=(c);++(a))
     29 #define DFOR(a,b,c) for (ll (a)=(b);(a)>=(c);--(a))
     30 #define FORSQ(a,b,c) for (ll (a)=(b);(a)*(a)<=(c);++(a))
     31 #define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
     32 #define FOREACH(a,b) for (auto &(a) : (b))
     33 #define rep(i,n) FOR(i,0,n)
     34 #define repn(i,n) FORN(i,1,n)
     35 #define drep(i,n) DFOR(i,n-1,0)
     36 #define drepn(i,n) DFOR(i,n,1)
     37 #define MAX(a,b) a = Max(a,b)
     38 #define MIN(a,b) a = Min(a,b)
     39 #define SQR(x) ((LL)(x) * (x))
     40 #define Reset(a,b) memset(a,b,sizeof(a))
     41 #define fi first
     42 #define se second
     43 #define mp make_pair
     44 #define pb push_back
     45 #define all(v) v.begin(),v.end()
     46 #define ALLA(arr,sz) arr,arr+sz
     47 #define SIZE(v) (int)v.size()
     48 #define SORT(v) sort(all(v))
     49 #define REVERSE(v) reverse(ALL(v))
     50 #define SORTA(arr,sz) sort(ALLA(arr,sz))
     51 #define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
     52 #define PERMUTE next_permutation
     53 #define TC(t) while(t--)
     54 #define forever for(;;)
     55 #define PINF 1000000000000
     56 #define newline '
    '
     57 
     58 #define test if(1)if(0)cerr
     59 using namespace std;
     60 using namespace std;
     61 typedef vector<int> vi;
     62 typedef vector<vi> vvi;
     63 typedef pair<int,int> ii;
     64 typedef pair<double,double> dd;
     65 typedef pair<char,char> cc;
     66 typedef vector<ii> vii;
     67 typedef long long ll;
     68 typedef unsigned long long ull;
     69 typedef pair<ll, ll> l4;
     70 const double pi = acos(-1.0);
     71 
     72 
     73 int main()
     74 {
     75     ios::sync_with_stdio(false);
     76     cin.tie(0);
     77     int T;  cin >> T;
     78     repn(kase, T)
     79     {
     80         cerr << "Case " << kase << newline;
     81         int n[2];
     82         rep(i, 2) cin >> n[i];
     83         vector<string> v[2];
     84         cerr << n[0] << " " << n[1] << newline;
     85         string temp;
     86         getline(cin, temp);
     87         rep(i, 2)
     88         {
     89             v[i].resize(n[i]);
     90             rep(j, n[i]) getline(cin, v[i][j]);
     91         }
     92         unordered_set<string> hashstr;
     93         rep(i, n[0]) rep(j, n[1])
     94         hashstr.insert(v[0][i]+v[1][j]);
     95         cout << "Case " << kase << ": " << hashstr.size() << newline;
     96         
     97     }
     98 }
     99 /*
    100  2
    101  3 2 cat dog mouse rat bat 1 1 abc cab
    102  */
    View Code
  • 相关阅读:
    流畅 最好用的远程桌面推荐下?
    高性能远程桌面Splashtop 居家办公首选软件
    ShareConnect即将寿终正寝 Splashtop远程桌面会是最好的替代品
    详解Springboot中自定义SpringMVC配置
    Java中使用RSA算法加密
    Docker搭建MySQL主从复制
    SpringMVC中RequestContextHolder获取请求信息
    详解Redis持久化(RDB和AOF)
    Redis事务
    Springboot CORS跨域访问
  • 原文地址:https://www.cnblogs.com/skyette/p/6358327.html
Copyright © 2020-2023  润新知