传送门
A:
#include<bits/stdc++.h>
#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define SC(n,m) scanf("%d %d",&n,&m)
#define SZ(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-9;
ll n;
ll run(int n){
if(n==2) return 2;
if(n<=0) return 0;
else return 2*run(n-2);
}
int main(){
std::ios::sync_with_stdio(0);
cin>>n;
if(n&1) cout<<0<<endl;
else{
cout<<run(n)<<endl;
}
return 0;
}
B:
#include<bits/stdc++.h>
#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define SC(n,m) scanf("%d %d",&n,&m)
#define SZ(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-9;
const int maxn=505;
int n,m;
char mp[maxn][maxn];
int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};
bool fg[maxn][maxn];
int run(int x,int y) {
fg[x][y]=1;
int res=1;
queue<pair<int,int> > q;
q.push(make_pair(x,y));
while(!q.empty()) {
pair<int,int> np=q.front();
q.pop();
for(int i=0; i<4; ++i) {
int nx=np.fi+dx[i],ny=np.se+dy[i];
if(nx>=1 && nx<=n && ny>=1 && ny<=m && !fg[nx][ny] && mp[nx][ny]=='*') {
res++;
fg[nx][ny]=1;
q.push(make_pair(nx,ny));
}
}
}
return res;
}
int main() {
std::ios::sync_with_stdio(0);
cin>>n>>m;
int num=0,x,y;
rep(i,1,n) {
rep(j,1,m) {
cin>>mp[i][j];
if(mp[i][j]=='*') {
num++;
x=i,y=j;
}
}
}
int cnt=run(x,y);
if(cnt==num) {
int ct=0;
rep(i,1,n) {
rep(j,1,m) {
if(mp[i][j]=='*') {
int cnt=0,fg=0;
if(mp[i][j-1]=='*') cnt++,fg+=1;
if(mp[i][j+1]=='*') cnt++,fg+=-1;
if(mp[i+1][j]=='*') cnt++,fg+=-2;
if(mp[i-1][j]=='*') cnt++,fg+=2;
if(cnt==4) ct++;
if((fg!=0 && cnt!=1) || ct>1) {
cout<<"NO"<<endl;
return 0;
}
}
}
}
if(ct==1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
} else cout<<"NO"<<endl;
return 0;
}
C:
#include<bits/stdc++.h>
#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define SC(n,m) scanf("%d %d",&n,&m)
#define SZ(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-9;
const int maxn=1e5+5;
int n;
struct node {
string s;
int num;
char ls;
} a[maxn];
bool cmp(node x,node y) {
if(x.ls==y.ls) return x.num<y.num;
else return x.ls<y.ls;
}
bool cmpna(node x,node y) {
return x.num<y.num;
}
bool vis[maxn],visna[maxn];
vector<pair<string,string> > bu,ans;
map<string,int> cc;
int main() {
std::ios::sync_with_stdio(0);
cin>>n;
string s;
int cnt=0;
char c;
rep(i,1,n) {
cin>>s;
cnt=0;
rep(j,0,SZ(s)-1) {
if(s[j]=='a' || s[j]=='e' || s[j]=='i' || s[j]=='o' || s[j]=='u') cnt++,c=s[j];
}
a[i]=node {s,cnt,c};
}
sort(a+1,a+n+1,cmp);
rep(i,1,n-1) {
if(vis[i]) continue;
if((a[i].num==a[i+1].num && a[i].ls==a[i+1].ls)) {
bu.pb(make_pair(a[i].s,a[i+1].s));
vis[i]=1,vis[i+1]=1;
}
}
vector<node> na;
rep(i,1,n) if(!vis[i]) na.pb(a[i]);
sort(na.begin(),na.end(),cmpna);
int bunum=0;
for(int i=0; i+1<SZ(na); ++i) {
if(visna[i]) continue;
if(na[i].num == na[i+1].num && bunum<SZ(bu)) {
ans.pb(make_pair(na[i].s,bu[bunum].fi));
ans.pb(make_pair(na[i+1].s,bu[bunum].se));
visna[i]=1,visna[i+1]=1;
bunum++;
}
if(bunum==SZ(bu)) break;
}
if(bunum+1<SZ(bu)) {
while(bunum<SZ(bu)) {
if(bunum+1<SZ(bu)) {
ans.pb(make_pair(bu[bunum].fi,bu[bunum+1].fi));
ans.pb(make_pair(bu[bunum].se,bu[bunum+1].se));
bunum+=2;
} else break;
}
}
cout<<SZ(ans)/2<<endl;
for(int i=0;i<SZ(ans);++i){
cout<<ans[i].fi<<" "<<ans[i].se<<endl;
}
return 0;
}