zoukankan      html  css  js  c++  java
  • 2019CCPC湖南全国邀请赛(广东省赛、江苏省赛)重现赛

    2019CCPC湖南全国邀请赛(广东省赛、江苏省赛)

    Can you raed it croretcly?(模拟)

    题解:模拟即可

    #include <bits/stdc++.h>
    #define P pair<int,int>
    #define fir first
    #define sec second
    using namespace std;
    typedef long long ll;
    
    const int N=2e5+5;
    const int mod=998244353;
    char a[30];
    char b[30];
    int main(){
    	while(~scanf("%s%s",a,b)){
    		if(a[0]!=b[0]||a[strlen(a)-1]!=b[strlen(b)-1]||strlen(a)!=strlen(b)){
    			puts("No");
    			continue;
    		}
    		else{
    			if(strcmp(a,b)==0){
    				puts("Equal");
    				continue;
    			}
    			map<char,int> ma,mb;
    			for(int i=0;i<strlen(a);i++){
    				ma[a[i]]++;
    				mb[b[i]]++;
    			}
    			if(ma==mb){
    				puts("Yes");
    			}
    			else{
    				puts("No");
    			}
    		}
    	}
    	return 0;
    }
    
    

    SSY and JLBD(模拟)

    题解:模拟即可

    #include <bits/stdc++.h>
    #define P pair<int,int>
    #define fir first
    #define sec second
    using namespace std;
    typedef long long ll;
    
    const int N=2e5+5;
    const int mod=998244353;
    map<string,int> m;
    string t[10]={
    "dong","nan","xi","bei","zhong","fa","bai"
    };
    int main(){
    	string s;
    	int f=0;
    	int ma=0;
    	string tmp="jj";
    	string hh;
    	for(int i=1;i<=14;i++){
    		cin>>s;
    		if(s[0]<='9'&&s[0]>='0'){
    			if(tmp=="jj") tmp=s[1];
    			if(s[1]!=tmp[0]) ma=1;
    		}
    		else ma=1;
    		if(m[s]==1&&f==0){
    			f=1;
    			string hh=s;
    			continue;
    		} 
    		m[s]++;
    	}
    	map<string,int>::iterator it=m.begin();
    	if(m["1w"]==1&&m["9w"]==1&&m["1p"]==1&&m["9p"]==1&&m["1s"]==1&&m["9s"]==1){
    		int f=0;
    		for(int i=0;i<7;i++){
    			if(m[t[i]]!=1) f=1;
    		}
    		if(f) puts("I dont know!");
    		else puts("shisanyao!");
    	}
    	else{
    		if(ma) puts("I dont know!");
    		else{
    			m[hh]++;
    			if(m["1"+tmp]>=3&&m["9"+tmp]>=3&&m["2"+tmp]>=1&&m["8"+tmp]>=1){
    				puts("jiulianbaodeng!");
    			}
    			else{
    				puts("I dont know!");
    			}
    		}
    	}
    	return 0;
    }
    
    

    Hello XTCPC(贪心)

    1.题解:用map<string,int>记录当前的组合,对于新加入的单个字符,放到刚好缺这个字符的组合后面.

    warning:要多组测试,多组测试,多组测试.不然wa到哭,比如我.

    tip: 题面锅有点大,懒得吐槽了.

    #include <bits/stdc++.h>
    #define P pair<int,int>
    #define fir first
    #define sec second
    using namespace std;
    typedef long long ll;
    
    const int N=2e5+5;
    const int mod=998244353;
    char s[N];
    //map<char,int> m;
    
    int main(){
    	int n;
    	while(~scanf("%d%s",&n,s)){
    		map<string,ll> st;
    		for(int i=0;i<n;i++){
    			if(s[i]=='x') st["x"]++;
    			else if(s[i]=='t'){
    				if(st["x"]>0) st["x"]--,st["xt"]++;
    			}
    			else if(s[i]=='C'){
    				if(st["xt"]>0) st["xt"]--,st["xtC"]++;
    			}
    			else if(s[i]=='p'){
    				if(st["xtC"]>0) st["xtC"]--,st["xtCp"]++;
    			}
    			else if(s[i]=='c'){
    				if(st["xtCp"]>0) st["xtCp"]--,st["xtCpc"]++;
    			}
    		}
    		cout<<st["xtCpc"]<<endl;
    	}
    	return 0;
    }
    
    

    2.题解:也可用队列记录每个字符的位置,然后贪心,挑出每个队列中符合条件的最前面的字符.直到有一个队列为空.

    #include <bits/stdc++.h>
    #define P pair<int,int>
    #define fir first
    #define sec second
    using namespace std;
    typedef long long ll;
    
    const int N=2e5+5;
    const int mod=998244353;
    char s[N];
    
    map<char,int> m;
    int main(){
    	m['x']=1;m['t']=2;m['C']=3;m['p']=4;m['c']=5;
    	int n;
    	while(~scanf("%d%s",&n,s)){
    		queue<int> q[10];
    		for(int i=0;i<n;i++){
    			q[m[s[i]]].push(i);
    			//cout<<m[s[i]]<<endl;
    		}
    		int ans=0;
    		while(!q[1].empty()){
    			int pos=q[1].front();
    			q[1].pop();
    			int f=0;
    			for(int i=2;i<=5;i++){
    				while(!q[i].empty()&&pos>q[i].front()) q[i].pop();
    				if(q[i].empty()){
    					f=1;
    					break;
    				}
    				else pos=q[i].front(),q[i].pop();
    			}
    			if(f) break;
    			else ans++;
    		}
    		cout<<ans<<endl;
    	}
    	return 0;
    }
    
    

    然后呢....不会了鸭,暴露了只会签到的水平.等之后补题.

  • 相关阅读:
    C#3.0入门系列(八)之GroupBy操作
    C#3.0入门系列(七)之OR工具介绍
    C#3.0入门系列(九)之GroupBy操作
    C#3.0入门系列(十二)Lambda表达式中Lifting
    C# 3.0入门系列(四)之Select操作
    图示offsetWidth clientWidth scrollWidth scrollTop scrollLeft等属性的细微区别
    C# 3.0入门系列(二)
    一步一步学Linq to sql(四):查询句法
    Linq To Sql进阶系列
    Linq To Sql进阶系列(二)M:M关系
  • 原文地址:https://www.cnblogs.com/-yjun/p/10891597.html
Copyright © 2011-2022 走看看