AC代码:
- #include
- #define endl '\n'
- //#define int long long
- using namespace std;
- int n;
- string s;
- void solve() {
- cin>>n>>s;
- s=' '+s;
- for(int i=1;i<=n-2;i++){
- if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
- cout<
- return;
- }
- }
- cout<<-1<
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int t=1;
- // cin>>t;
- while(t--) {
- solve();
- }
- return 0;
- }
AC代码:
- #include
- #define endl '\n'
- //#define int long long
- using namespace std;
- int n,m;
- string s,t;
- void solve() {
- cin>>n>>m;
- cin>>s>>t;
- bool ok1=true;
- for(int i=0,j=0;i
- if(s[i]!=t[j++]){
- ok1=false;
- break;
- }
- }
- bool ok2=true;
- for(int i=n-1,j=m-1;i>=0;i--){
- if(s[i]!=t[j--]){
- ok2=false;
- break;
- }
- }
- if(ok1&&ok2) cout<<0<
- else if(ok1&&!ok2) cout<<1<
- else if(!ok1&&ok2) cout<<2<
- else cout<<3<
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int t=1;
- // cin>>t;
- while(t--) {
- solve();
- }
- return 0;
- }
AC代码:
- #include
- #define endl '\n'
- //#define int long long
- using namespace std;
- const int N=2e5+10;
- int a[N];
- int n,m;
- void solve() {
- cin>>n>>m;
- for(int i=1;i<=m;i++) cin>>a[i];
- for(int i=1;i<=n;i++){
- int id=lower_bound(a+1,a+1+m,i)-a;
- }
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int t=1;
- // cin>>t;
- while(t--) {
- solve();
- }
- return 0;
- }
暴力
图形的旋转平移
枚举三个图案旋转平移的所有情况,通过状态压缩,转化为一个二进制串,0~15位,如果该格为#,那么就为1
三个图案的二进制串按位或,如果等于2^(SIZE*SIZE)-1,那么说明三个图案把正方形填满了,如果任意两个图案二进制串按位与不等于0,那么说明图案有重叠
AC代码:
- #include
- #define SIZE 4
- #define endl '\n'
- //#define int long long
- using namespace std;
- //逆时针旋转90度
- void rotate(string s[]){
- char temp[SIZE][SIZE];//中间变量
- for(int i=0;i
- for(int j=0;j
- temp[SIZE-j-1][i]=s[i][j];
- }
- }
- for(int i=0;i
- for(int j=0;j
- s[i][j]=temp[i][j];
- }
- }
- }
- //判断合法性
- bool valid(int x){
- return x>=0&&x
- }
- //平移
- int get(string s[],int dx,int dy){
- int ret=0;//ret存储二进制串
- for(int x=0;x
- for(int y=0;y
- if(s[x][y]=='#'){
- int tx=x+dx;
- int ty=y+dy;
- if(!valid(tx)||!valid(ty)) return -1;
- ret|=1<<(tx*4+ty);
- }
- }
- }
- return ret;//返回图案所对应的二进制串
- }
- vector<int>add(int id){
- vector<int>ret;
- string s[SIZE];
- for(int i=0;i
>s[i]; - for(int i=0;i<4;i++){
- for(int dx=-3;dx<=3;dx++){
- for(int dy=-3;dy<=3;dy++){
- int v=get(s,dx,dy);
- if(v>=0) ret.push_back(v);
- }
- }
- rotate(s);
- }
- return ret;
- }
- void solve() {
- vector<int>mask[3];
- for(int id=0;id<3;id++) mask[id]=add(id);
- for(int x:mask[0]){
- for(int y:mask[1]){
- for(int z:mask[2]){
- if((x|y|z)!=(1<
-1) continue; - if(x&y) continue;
- if(x&z) continue;
- if(y&z) continue;
- cout<<"Yes"<
- return;
- }
- }
- }
- cout<<"No"<
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int t=1;
- // cin>>t;
- while(t--) {
- solve();
- }
- return 0;
- }
-
相关阅读:
1个月时间整理了2019年上千道Java面试题,近500页文档!
猿创征文 |【Linux】常用命令
【数据结构】栈和队列的模拟实现
计算机网络--应用层(https)
【Java】Netty创建网络服务端客户端(TCP/UDP)
mq学习方式
网络吞吐量 公网带宽有关吗?
时间序列问题案例分析Kaggle M5 Forecasting
Redis主从复制、哨兵以及Cluster集群
企业数据挖掘平台产品特色及合作案例介绍
-
原文地址:https://blog.csdn.net/m0_74087709/article/details/133517065