题目 题目oj(洛谷) Farmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with N stacks, each containing a single cube. Farmer John asks Betsy to perform P (1<= P <= 100,000) operation. There…
用了STL,其他的没什么,赤裸裸的拓扑排序 下面给出代码 #include<cstdio> #include<iostream> #include<vector> #include<stack> using namespace std; int n,m,u,v; +],dis[+]; vector<+]; stack<int>str ; int main(){ cin >> n >> m; while(m--){ s…
题目链接 \(Click\) \(Here\) 关键在于转换成阶梯\(Nim\)的模型.最开始把题目看错了,理解正确后发现棋子可以向后跳不止一位,那么就比较简单了. 这里把空格看做阶梯,棋子看做硬币,这样整个模型就满足阶梯\(Nim\)的性质了.阶梯\(Nim\)的证明我不会,请自己\(yy\). #include <bits/stdc++.h> using namespace std; const int M = 30; const int N = 1010; int n, t, a[M],…