题解:P10612 [Baltic2001] Box of Mirrors
可能更好的阅读体验
题目
题解
由于光路可逆,我们只需观察左下两侧,分别编号为
对于一面镜子
我们假设不加这面镜子前,从
我们现在求出
现在我们试图找到上一步的
因此我们选择一个直接相邻的两个点
但我们现在需要找到尽可能靠后加入的镜子,根据上述描述,越靠后的镜子
代码
/* C++17 is required!
* By Koicy (https://koicy.ly)
* Email [email protected]
* 我还期待着名为奇迹的魔法,哪怕会凋零会消散只会是一场浮华,我笑纳!
__ __ __ _
_____/ /_ / /_________ ___ / /______ (_)______ __
/ ___/ __ \/ __/ ___/ _ \/ _ \ ______ / //_/ __ \/ / ___/ / / /
/ / / /_/ / /_/ / / __/ __/ /_____/ / ,< / /_/ / / /__/ /_/ /
/_/ /_.___/\__/_/ \___/\___/ /_/|_|\____/_/\___/\__, /
SIGN /___*/
#define __NO_MAIN__ false
#define __ENABLE_RBLIB__ true
constexpr bool _MTS = false, SPC_MTS = false;
constexpr char EFILE[] = "";
#include <bits/stdc++.h>
#define FULL(arg) arg.begin(), arg.end()
// :/
using namespace std;
using tp = long long int;
using vetp = basic_string<tp>;
[[maybe_unused]] constexpr tp ZERO = 0, ONE = 1, INF = -1ull >> 2;
signed STRUGGLING(unsigned long long int);
void MIST();
#if !__NO_MAIN__
int main(int argc, char* argv[]) {
unsigned long long int t = 0, _t = 1;
MIST();
if (_MTS && !SPC_MTS) cin >> _t;
while (t < _t || SPC_MTS) {
if (STRUGGLING(++t) != 0) return 0;
}
return 0;
}
#endif
#ifdef XCODE
#define bg(...){bin<<"[#"<<__LINE__<<'@'<<++_LT[__LINE__]<<':';BG(__VA_ARGS__);}
size_t _LT[21777]; template<typename _Type>void BG(const _Type&_cur){cout<<' '<<
_cur << ']' << " <<:" << endl; } template<typename _Type,typename... _Other>void
BG(const _Type& _cur, const _Other& ..._other) {cout<< ' '<<_cur;BG(_other...);}
#else
#define bg(...)
#define dputs(...)
#endif
// :/
// :/
signed STRUGGLING([[maybe_unused]] unsigned long long int TEST_NUMBER) {
tp n, m; cin >> n >> m;
vetp c(2 * n + 2 * m + 1, 0);
for (tp i = 1; i <= 2 * n + 2 * m; ++i) cin >> c[i];
vetp b(n + m + 1, 0);
for (tp i = 1; i <= n + m; ++i) {
tp x = i <= n ? 1 + n + m + n : n + 1 + n * 2 + m * 2;
x -= i;
b[i] = c[x];
}
vector a(n + 1, vetp(m + 1, 0));
for (tp i = 1; i <= n; ++i) {
for (tp j = n + m; j > n; --j) {
if (b[i] == j || b[j] == i) {
swap(b[i], b[j]);
a[i][j - n] = 1;
}
}
}
for (tp i = 1; i <= n; ++i) {
for (tp j = 1; j <= m; ++j) cout << a[i][j] << ' ';
cout << '\n';
}
return 0;
}
void MIST() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
// :\ */