codeforces 589a(构造的字符串后,最后要加终止符,,,)

Posted 十目

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 589a(构造的字符串后,最后要加终止符,,,)相关的知识,希望对你有一定的参考价值。

模拟注意细节,没什么好说的
#include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include <iostream> #include <map> #include <queue> #include <stack> #include <cmath> //#pragma comment(linker, "/STACK:102400000,102400000") using namespace std; #define PF(x) cout << "debug: " << x << " "; #define EL cout << endl; #define PC(x) puts(x); typedef long long ll; #define CLR(x, v) sizeof (x, v, sizeof(x)) using namespace std; const int INF = 0x5f5f5f5f; const int maxn = 2e4 + 10; const int mod = 1e9 + 7; const double eps = acos(-1); const double PI= atan(1.0)*4; map<string,int>q,q1; vector<string>st[maxn]; int n,cnt; char ck[20] = {"bmail.com"}; int main(){ // freopen("in.txt","r",stdin); cin>>n; // cout<<n<<endl; // cout<<ck<<endl; //for(int i = 0;i < 9;i++) // cout<<ck[i]<<endl; int num = a - A + 0; //cout<<num<<endl; char ss[350]; for(int i = 1;i <= n;i++){ // char ss[350]; char ss1[350],ss2[350]; scanf("%s",ss); //cout<<ss<<endl; int l = strlen(ss); int cnt1 = -1,cnt2 = -1,fg = 0,fg2 = 0,pos; for(int j = 0;j < l;j++){ if(ss[j] >= A&&ss[j] <= Z){ ss1[++cnt1] = ss[j] + num; if(fg2 == 0||fg2 == 2) ss2[++cnt2] = ss[j] + num; // cout<<ss1[cnt1]<<endl; } if(ss[j] >= a&&ss[j] <= z){ ss1[++cnt1] = ss[j]; if(fg2 == 0||fg2 == 2) ss2[++cnt2] = ss[j]; } if(ss[j] == .){ ss1[++cnt1] = ss[j]; if(fg2 == 2) ss2[++cnt2] = ss[j]; } if(ss[j] == +){ ss1[++cnt1] = ss[j]; fg2 = 1; } if(ss[j] == @){ pos = j; fg2 = 2; ss1[++cnt1] = @; ss2[++cnt2] = @; } //cout<<ss1[cnt1]<<endl; } int t = 0; pos++; if(l - pos == 9) for(t = pos;t < l;t++){ // cout<<ss[t]<<endl; // cout<<ck[t-pos]<<endl; if(t != pos + 5){ //cout<<ss[t]<<" "<<ck if(ss[t] != ck[t-pos]&&ss[t] != ck[t-pos]-num) break; } else{ if(ss[t] != .) break; } } //cout<<ss1<<" "<<ss2<<endl; // printf("%s %s\n",ss1,ss2); for(int i = cnt1+1;i < strlen(ss1);i++) ss1[i] = \0; for(int i = cnt2+1;i< strlen(ss2);i++) ss2[i] = \0; // cout<<" "; // cout<<ss1<<" "<<ss2<<endl; if(t == l) fg = 1; //cout<<fg<<endl;*/ if(fg == 0){ if(q[ss1] > 0) st[q[ss1]].push_back(ss); else{ q[ss1] = ++cnt; st[cnt].push_back(ss); } } else{ if(q1[ss2] > 0) st[q1[ss2]].push_back(ss); else{ q1[ss2] = ++cnt; st[cnt].push_back(ss); } } } cout<<cnt<<endl; for(int i = 1;i <= cnt;i++){ int num1 = st[i].size(); printf("%d ",num1); for(int j = 0;j < num1;j++){ cout<<st[i][j]; if(j == num1 - 1) printf("\n"); else printf(" "); } } return 0; }

 

以上是关于codeforces 589a(构造的字符串后,最后要加终止符,,,)的主要内容,如果未能解决你的问题,请参考以下文章

CodeForces - 589A(二分+贪心)

codeforces 848A - From Y to Y(构造)

Codeforces Round #650 (Div. 3) D. Task On The Board (构造,贪心)

CodeForces - 748D Santa Claus and a Palindrome (贪心+构造)

Codeforces Round #723 (Div. 2) D. Kill Anton (字符串构造,全排列)

codeforces615c