A Amateur Chess Players
题意比题难系列…实际上就是先手的棋子个数只能大于后手他才能赢否则必输
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define lowbit(x) (x&(-x))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps=1e-8;
const double pi=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;
const int Mod=1e9+7;
const int maxn=2e5+10;
char s1[10],s2[10];
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
//ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n,m;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%s",s1);
scanf("%d",&m);
for(int i=0;i<m;i++)
scanf("%s",s2);
//cout<<n<<m<<endl;
if(n>m) puts("Cuber QQ");
else puts("Quber CC");
return 0;
}
C Coronavirus Battle
留坑
D Decay of Signals
留坑
F Find / -type f -or -type d
第一遍,没读懂题意,然后读了前后十几遍,总算搞明白怎么回事了。实际上就是按文件的前缀展开可以得到一颗前缀树,然后去判断 . e o j .eoj .eoj的文件是否出现即可
第一次我这么想,只看每个字符串的末尾出现多少次,那么最后map中出现0次的包含 . e o j .eoj .eoj的就是符合要求的文件。这里有个致命的错误,如果映射到map中,同一个名字只能被映射为一个,也就是说如果目录名和文件名相同,那么就会产生错误
然后过了差不多两个小时才想出来正解。正解是首先排序恢复,那么对每一个判断前面的文件是否为它的前缀,如果不是就看它的末尾是否出现 . e o j .eoj .eoj即可
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define lowbit(x) (x&(-x))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps=1e-8;
const double pi=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;
const int Mod=1e9+7;
const int maxn=1e6+10;
string s,buf;
string str[maxn];
int cnt;
bool isContain(string res){
int len=res.size();
if(len<4) return false;
if(res[len-1]=='j' && res[len-2]=='o' && res[len-3]=='e' && res[len-4]=='.')
return true;
return false;
}
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n;
cin>>n;
vector<string> ans;
for(int i=1;i<=n;i++){
cin>>s;
ans.push_back(s);
}
sort(ans.begin(),ans.end());
int num=0;
for(int i=1;i<ans.size();i++){
if(ans[i].find(ans[i-1])==-1){
if(isContain(ans[i-1])) num++;
}
}
int last=ans.size()-1;
if(isContain(ans[last])) num++;
cout<<num<<endl;
return 0;
}
I Idiotic Suffix Array
首先将第 k − 1 k-1 k−1个字符的后缀串设为最小,那么它设为’a’,后面的全设置为’z’
接着满足整个串是第k小,实际上就是从 k − 1 k-1 k−1到 0 0 0不断的递增即可,考虑长度一步步增加,那么全设置为大于’a’且小于’z’的一个字符即可
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define lowbit(x) (x&(-x))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps=1e-8;
const double pi=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;
const int Mod=1e9+7;
const int maxn=2e5+10;
string s;
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n,k;
cin>>n>>k;
s.clear();
for(int i=0;i<k-1;i++) s+='b';
s+='a';
for(int i=k;i<n;i++) s+='z';
cout<<s<<endl;
return 0;
}