当前位置:网站首页>acwing-飞行员兄弟
acwing-飞行员兄弟
2022-07-22 11:07:00 【ai_moe】
题目详情
解题代码
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef pair<int,int> PII;
char g[10][10],backup[10][10];
int get(int i,int j)
{
return i*4+j;
}
void turn_one(int x,int y)
{
if(g[x][y]=='+') g[x][y]='-';
else g[x][y]='+';
}
void turn_all(int x,int y)
{
for(int i=0;i<4;i++) turn_one(x,i);
for(int i=0;i<4;i++) turn_one(i,y);
turn_one(x,y);
}
int main()
{
for(int i=0;i<4;i++) cin >> g[i];
vector<PII> res;
for(int op=0;op < 1<<16;op++)
{
vector<PII> tmp;
memcpy(backup,g,sizeof g);
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
{
if(op & (1<<get(i,j)))
{
tmp.push_back({
i,j});
turn_all(i,j);
}
}
bool close=false;
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
if(g[i][j]=='+') close=true;
if(!close)
{
if(res.empty() || res.size()<tmp.size()) res=tmp;
}
memcpy(g,backup,sizeof g);
}
cout << res.size() << endl;
for(int i=0;i<res.size();i++)
{
cout << res[i].first +1<< " " << res[i].second+1<<endl;
}
return 0;
}
边栏推荐
- 6. Manage servers and services
- [lttng learning journey] - simply add a trace point to the user program
- Chapter 7: login using JWT token
- Significance learning record of FFT in MATLAB
- Buuctf breakthrough diary 04 -- [strong net cup 2019] casual note 1
- JUC-6.2-并发容器-CopyOnWriteArrayList
- 人类群星网站收集计划--Michael Kerrisk
- JUC-7.1-线程协作-Semaphore
- Using openresty as the gateway to authenticate and access static resources
- Condition judgment
猜你喜欢
随机推荐
YOLO9000: Better, Faster, Stronger
嵌入式系统学习笔记
PKG config lookup library and for compilation
Buuctf breakthrough diary --[mrctf2020]ez_ bypass1
Embedded system learning notes
8.内存与磁盘管理
Software package management RPM package management checksum file extraction
Interview shock 67: talk about tcp/ip protocol? And the role of each layer?
Wechat applet introduction tutorial learning notes
新生儿,脑区分割资料
Application & rich text editor & file upload
1.虚拟化和容器技术
[lttng learning journey] - trace control - Preliminary
校园IPTV数字电视教学直播系统在淮安生态文旅区实验小学的应用
校园IP网络广播案例-石家庄法商中等专业学校鹿泉校区校园IP广播系统应用
Bash basic function - input / output redirection
编译gdb7.11.1报错解决
小区IP网络广播背景系统解决方案-基于局域网、专网或广域网传输
Buuctf breakthrough diary --[mrctf2020]ezpop1
Bash variables - numeric operations and operators