Little Sub and Enigma
生活随笔
收集整理的這篇文章主要介紹了
Little Sub and Enigma
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://acm.hznu.edu.cn/OJ/problem.php?cid=1263&pid=8
http://acm.hznu.edu.cn/OJ/problem.php?id=2587
題意:26個小寫字母有一組雙射,求從讀入的數據中能觀察或推導出的關系。
題解:開數組統計對應關系,判斷是否矛盾,輸出。
? Corner Case 1:解密串是否有兩個字母對應到同一個字母
? Corner Case 2:加密串是否有兩個字母對應到同一個字母
? Corner Case 3:如果推出了25組關系,那么第26組關系也隨之確定
題解:
25字母推測26字母是什么東西
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int using namespace std; typedef long long ll; //typedef __int128 lll; const int N=10000000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,q; int ans,cnt,flag,temp,sum; int a[N]; char str1[N]; char str2[N]; int mp[258]; int mpv[258]; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%s%s",str1,str2);int len=strlen(str1);for(int i=0;i<len;i++){if(mp[str1[i]]==0||mp[str1[i]]==str2[i]){mp[str1[i]]=str2[i];}else{cout<<"Impossible"<<endl;return 0;}if(mpv[str2[i]]==0||mpv[str2[i]]==str1[i]){mpv[str2[i]]=str1[i];}else{cout<<"Impossible"<<endl;return 0;}}for(int i=97;i<=96+26;i++){if(mp[i]){cnt++;//printf("%c->%c\n",i,mp[i]);}}if(cnt==25){int a;int b;for(int i=97;i<=96+26;i++){if(!mp[i]){a=i;break;}}for(int i=97;i<=96+26;i++){if(!mpv[i]){b=i;break;}} mp[a]=b;mpv[b]=a;}for(int i=97;i<=96+26;i++){if(mp[i]){cnt++;printf("%c->%c\n",i,mp[i]);}}//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }?
總結
以上是生活随笔為你收集整理的Little Sub and Enigma的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Little Sub and Count
- 下一篇: Little Sub and Apple