A - Spoiler
竖线里面的不要输出,竖线只有一对,且出现一次。
#include <bits/stdc++.h>
//#define int long long
#define per(i,j,k) for(int (i)=(j);(i)<=(k);++(i))
#define rep(i,j,k) for(int (i)=(j);(i)>=(k);--(i))
#define debug(a) cout<<#a<<"="<<a<<endl
#define fr first
#define se second
#define endl '\n'
using namespace std;void solve(){string s;cin>>s;int next;per(i,0,s.length()-1){if(s[i]=='|'){next=i;break;}else cout<<s[i];}per(i,next+1,s.length()-1){if(s[i]=='|'){next=i;break;}}per(i,next+1,s.length()-1){cout<<s[i];}
}signed main(){ios::sync_with_stdio(false),cin.tie(nullptr);int t=1;while(t--)solve();return 0;
}
B - Delimiter
不告诉你几个数的输入,但是最多100个,正序输入,倒序输出。
#include <bits/stdc++.h>
//#define int long long
#define per(i,j,k) for(int (i)=(j);(i)<=(k);++(i))
#define rep(i,j,k) for(int (i)=(j);(i)>=(k);--(i))
#define debug(a) cout<<#a<<"="<<a<<endl
#define fr first
#define se second
#define endl '\n'
using namespace std;void solve(){int a[105];int n=0;while(cin>>a[n]){n++;}rep(i,n-1,0){cout<<a[i]<<endl;}
}signed main(){ios::sync_with_stdio(false),cin.tie(nullptr);int t=1;while(t--)solve();return 0;
}
C - A+B+C
x[i] 是否可以被a,b,c里面各取一个相加,相等。
范围很小,直接暴力。
#include <bits/stdc++.h>
//#define int long long
#define per(i,j,k) for(int (i)=(j);(i)<=(k);++(i))
#define rep(i,j,k) for(int (i)=(j);(i)>=(k);--(i))
#define debug(a) cout<<#a<<"="<<a<<endl
#define fr first
#define se second
#define endl '\n'
using namespace std;void solve(){int n;cin>>n;int a[n+1];per(i,1,n)cin>>a[i];int m;cin>>m;int b[m+1];per(i,1,m)cin>>b[i];int l;cin>>l;int c[l+1];per(i,1,l)cin>>c[i];int q;cin>>q;int x[q+1];per(i,1,q)cin>>x[i];map<int,bool>f;per(i,1,n){per(j,1,m){per(k,1,l){f[a[i]+b[j]+c[k]]=true;}}}per(i,1,q){if(f[x[i]])cout<<"Yes"<<endl;else cout<<"No"<<endl;}
}signed main(){ios::sync_with_stdio(false),cin.tie(nullptr);int t=1;while(t--)solve();return 0;
}
D题搜索剪枝一路剪到了只T4个点。
再怎么剪也剪不出来了,直接寄!(感觉不如转战去E)