Skip to main content
  1. Posts/

poj 2159 Ancient Cipher(水)

·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

由于顺序是可以改变的. 所以考虑是否可以映射.只要存在字母对应出现的次数都相同.那么就可以通过映射得到. 具体是开一个数组记录每个字母出现的次数… 然后sort

 1/*************************************************************************
 2	> File Name: code/poj/2159.cpp
 3	> Author: 111qqz
 4	> Email: rkz2013@126.com
 5	> Created Time: 2015年09月23日 星期三 19时04分34秒
 6 ************************************************************************/
 7
 8#include<iostream>
 9#include<iomanip>
10#include<cstdio>
11#include<algorithm>
12#include<cmath>
13#include<cstring>
14#include<string>
15#include<map>
16#include<set>
17#include<queue>
18#include<vector>
19#include<stack>
20#include<cctype>
21#define y1 hust111qqz
22#define yn hez111qqz
23#define j1 cute111qqz
24#define ms(a,x) memset(a,x,sizeof(a))
25#define lr dying111qqz
26using namespace std;
27#define For(i, n) for (int i=0;i<int(n);++i)
28typedef long long LL;
29typedef double DB;
30const int inf = 0x3f3f3f3f;
31const int N=30;
32string st1,st2;
33int len;
34int a[N],b[N];
35
36
37bool cmp( int a,int b)
38{
39    if (a>b) return true;
40    return false;
41}
42int main()
43{
44  #ifndef  ONLINE_JUDGE
45   freopen("in.txt","r",stdin);
46  #endif
47   ms(a,0);
48   ms(b,0);
49   cin>>st1>>st2;
50   len = st1.length();
51  // cout<<st1<<endl<<st2<<endl;
52   for ( int i = 0 ; i < len ; i ++)
53    {
54	int tmp = st1[i]-'A';
55	a[tmp]++;
56	tmp = st2[i]-'A';
57	b[tmp]++;
58    }
59
60   sort(a,a+26,cmp);
61   sort(b,b+26,cmp);
62  //  for ( int i = 0 ; i < 26 ; i++) cout<<"a[i]:"<<a[i]<<" b[i]"<<b[i]<<endl;
63
64   bool flag = true;
65   for ( int i = 0 ; i < 26 ; i++)
66    {
67	if (a[i]!=b[i])
68	{
69	    flag = false;
70	    break;
71	}
72    }
73   if (flag)
74    {
75	puts("YES");
76    }
77   else
78    {
79	puts("NO");
80    }
81
82
83 #ifndef ONLINE_JUDGE
84  fclose(stdin);
85  #endif
86	return 0;
87}

Related

codeforces #317 div2 A. Arrays (水)

·1 min
应该3分钟过的题。。。 结果花了8分钟。。。ssssad 1/************************************************************************* 2 > File Name: code/cf/#317/A.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月23日 星期日 00时29分47秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#include<cctype> 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define ms(a,x) memset(a,x,sizeof(a)) 25#define lr dying111qqz 26using namespace std; 27#define For(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef double DB; 30const int inf = 0x3f3f3f3f; 31const int N=1E5+7; 32int na,nb,k,m; 33int a[N],b[N]; 34int main() 35{ 36 #ifndef ONLINE_JUDGE 37 freopen("in.txt","r",stdin); 38 #endif 39 cin>>na>>nb; 40 cin>>k>>m; 41 for ( int i = 1 ; i <= na ; i++){ 42 scanf("%d",&a[i]); 43 } 44 for ( int i = 1 ; i<= nb ; i++){ 45 scanf("%d",&b[i]); 46 } 47 if (a[k]<b[nb-m+1]){ 48 puts("YES"); 49 } 50 else 51 { 52 puts("NO"); 53 } 54 55 56 #ifndef ONLINE_JUDGE 57 fclose(stdin); 58 #endif 59 return 0; 60}

acm博弈论

·10 mins
**序:**博弈是信息学和数学试题中常会出现的一种类型,算法灵活多变是其最大特点,而其中有一类试题更是完全无法用常见的博弈树来进行解答。 寻找必败态即为针对此类试题给出一种解题思路。