传送门
题意
思路
暴力枚举每一个妆台的转换条件
code
#include<iostream>
#include<cstdio>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define long long
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int INF = 1e18 + 10;
const int N = 1e5 + 10;
const int M = 1e7 + 10;
const int mod = 1e9 + 7;
int n, m, k, ans;
int qcal(int a, int b) { int res = 1; while (b) { if (b & 1) res = res * a % mod; b >>= 1; a = a * a % mod; } return res; }
int a[N], b[N];
bool is_prime(int n) { if (n < 2) return false; for (int i = 2; i <= n / i; i++) { if (n % i == 0) { return false; } }return true; }
int f[1010][1010];
void gzy()
{}
signed main()
{IOS;int _ = 1; cin >> _;while (_--) gzy();return 0;
}
/*** ┏┓ ┏┓+ +* ┏┛┻━━━┛┻┓ + +* ┃ ┃* ┃ ━ ┃ ++ + + +* ████━████+* ◥██◤ ◥██◤ +* ┃ ┻ ┃* ┃ ┃ + +* ┗━┓ ┏━┛* ┃ ┃ + + + +Code is far away from * ┃ ┃ + bug with the animal protecting* ┃ ┗━━━┓ 神兽保佑,代码无bug * ┃ ┣┓* ┃ ┏┛* ┗┓┓┏━┳┓┏┛ + + + +* ┃┫┫ ┃┫┫* ┗┻┛ ┗┻┛+ + + +*/
很可惜 这样T了
原因在每次都memset了1010*1010
题目说了n*m <= 2e5 所以我们应该手写 清零
#include<iostream>
#include<cstdio>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define long long
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int INF = 1e18 + 10;
const int N = 1e5 + 10;
const int M = 1e7 + 10;
const int mod = 1e9 + 7;
int n, m, k, ans;
int qcal(int a, int b) { int res = 1; while (b) { if (b & 1) res = res * a % mod; b >>= 1; a = a * a % mod; } return res; }
int a[N], b[N];
bool is_prime(int n) { if (n < 2) return false; for (int i = 2; i <= n / i; i++) { if (n % i == 0) { return false; } }return true; }
int f[1010][1010];
void gzy()
{cin >> n >> m >> k;for(int i = 0;i <= m;i ++)for(int j = 0;j <= n;j ++)f[i][j] = 0;f[0][k] = 1;for(int i = 1;i <= m;i ++){int tmp;char ch; cin >> tmp >> ch;for(int j = 1;j <= n;j ++){if(ch == '0') {if((j+n-tmp) % n == 0) f[i][j] = max(f[i][j],f[i-1][n]);else f[i][j] = max(f[i][j],f[i-1][(j+n-tmp) % n]);}else if(ch == '1'){if((j+tmp) % n == 0) f[i][j] = max(f[i][j],f[i-1][n]);else f[i][j] = max(f[i][j],f[i-1][(j+tmp) % n]);}else{if((j+n-tmp) % n == 0) f[i][j] = max(f[i][j],f[i-1][n]);else f[i][j] = max(f[i][j],f[i-1][(j+n-tmp) % n]);if((j+tmp) % n == 0) f[i][j] = max(f[i][j],f[i-1][n]);else f[i][j] = max(f[i][j],f[i-1][(j+tmp) % n]);}}}set<int> se;int cnt = 0;for(int i = 1;i <= n;i ++)if(f[m][i]){cnt ++;se.insert(i);}cout << cnt << endl;for(auto c:se) cout << c << ' ';cout << endl;}
signed main()
{IOS;int _ = 1; cin >> _;while (_--) gzy();return 0;
}
/*** ┏┓ ┏┓+ +* ┏┛┻━━━┛┻┓ + +* ┃ ┃* ┃ ━ ┃ ++ + + +* ████━████+* ◥██◤ ◥██◤ +* ┃ ┻ ┃* ┃ ┃ + +* ┗━┓ ┏━┛* ┃ ┃ + + + +Code is far away from * ┃ ┃ + bug with the animal protecting* ┃ ┗━━━┓ 神兽保佑,代码无bug * ┃ ┣┓* ┃ ┏┛* ┗┓┓┏━┳┓┏┛ + + + +* ┃┫┫ ┃┫┫* ┗┻┛ ┗┻┛+ + + +*/