题意是给出一个3*3的黑白网格,每点击其中一格就会使某些格子的颜色发生转变,求达到目标状态网格的操作.可用BFS搜索解答,用vector储存每次的操作 #include<bits/stdc++.h> using namespace std; struct Node{ int num;//储存状态 vector<int> path;//储存操作 }; ]; int click(int i, int num){ ; switch(i){ :tmp = num ^ ; break;//点…
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5646 Accepted: 1226 Description In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p: ⊕ is the xor operator. We say a path the xor-l…
Description Flip game squares. One side of each piece is white and the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 pieces, thus changing the color of their upper side from black to white a…
Descroption 原题链接 你有一个\(n*m\)的矩形,一开始所有格子都是白色,然后给出一个目标状态的矩形,有的地方是白色,有的地方是黑色,你每次可以选择一个连通块(四连通块,且不要求颜色一样)进行染色操作(染成白色或者黑色).问最少操作次数.\(1 \leq n, m, \leq 50.\) Solution 对目标矩形的同色联通块缩点,向相邻的异色联通块连边,代表先把该块和它所有相邻的块染成同色,再把该块染成异色.至于为什么是最优的我也不知道,考场上手玩出来的qwq那么这个图的某一颗…