参考答案(仅供参考):
P11227 [CSP-J 2024] 扑克牌(民间数据)
using namespace std;
typedef long long ll;
int n;
set<string> st;
string s;
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll i, j;
cin>>n;
for(i=1; i<=n; i++)
{
cin>>s;
st.insert(s);
}
cout<<52-st.size();
return 0;
}
P11228 [CSP-J 2024] 地图探险(民间数据)
using namespace std;
typedef long long ll;
int t;
int n, m, k;
int x, y, d;
string s;
int a[1005][1005];
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll i, j;
cin>>t;
while(t--)
{
cin>>n>>m>>k;
cin>>x>>y>>d;
memset(a, 0, sizeof a);
for(i=1; i<=n; i++)
{
cin>>s;
s = ' ' + s;
for(j=1; j<=m; j++)
{
if(s[j] == '.')
a[i][j] = 0;
else
a[i][j] = -1;
}
}
a[x][y] = 1;
for(i=1; i<=k; i++)
{
int x1, y1;
if(d == 0)
x1 = x, y1 = y+1;
else if(d == 1)
x1 = x+1, y1 = y;
else if(d == 2)
x1 = x, y1 = y-1;
else if(d == 3)
x1 = x-1, y1 = y;
if(1<=x1 && x1 <= n && 1<=y1 && y1 <= m && a[x1][y1] >= 0)
x = x1, y = y1, a[x][y] = 1;
else
d = (d+1)%4;
}
int ans = 0;
for(i=1; i<=n; i++)
for(j=1; j<=m; j++)
if(a[i][j] == 1)
ans++;
cout<<ans<<endl;
}
return 0;
}
P11229 [CSP-J 2024] 小木棍(民间数据)
using namespace std;
typedef long long ll;
int c[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int ans[100100];
int t, n;
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll i, j;
ans[1] = -1;
ans[2] = 1;
ans[3] = 7;
ans[4] = 4;
ans[5] = 2;
ans[6] = 6;
ans[7] = 8;
ans[8] = 10;
ans[9] = 18;
ans[10] = 22;
ans[11] = 20;
ans[12] = 28;
ans[13] = 68;
ans[14] = 88;
ans[15] = 108;
ans[16] = 188;
ans[17] = 200;
ans[18] = 208;
ans[19] = 288;
ans[20] = 688;
ans[21] = 888;
cin>>t;
while(t--)
{
cin>>n;
if(n<=20)
cout<<ans[n]<<endl;
else
{
int s = n/7-2;
int z = n%7+14;
cout<<ans[z];
for(i=1; i<=s; i++)
cout<<8;
cout<<endl;
}
}
return 0;
}
P11230 [CSP-J 2024] 接龙(民间数据)
using namespace std;
typedef long long ll;
int t;
int n, k, q;
int li[100100];
vector<int>s[100100], ok[100100];
struct dd
{
int r, c;
}dat[100100];
bool vis[102][200100];
int p[200100];
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll i, j;
int tp;
cin>>t;
while(t--)
{
cin>>n>>k>>q;
memset(vis, 0, sizeof vis);
for(i=1; i<=n; i++)
{
cin>>li[i];
s[i].clear();
s[i].push_back(0);
ok[i].clear();
ok[i].resize(li[i]+1);
for(j=1; j<=li[i]; j++)
{
cin>>tp;
s[i].push_back(tp);
}
}
for(i=1; i<=q; i++)
{
cin>>dat[i].r>>dat[i].c;
}
for(i=1; i<=n; i++)
for(j=1; j<=li[i]; j++)
if(s[i][j] == 1)
ok[i][j] = 1;
else
ok[i][j] = 0;
for(i=1; i<=100; i++)
{
for(j=1; j<=200000; j++)
p[j] = 0;
for(j=1; j<=n; j++)
{
int lst = -1e6;
for(int z=1; z<=li[j]; z++)
{
if(z-lst+1 <= k)
{
if(p[s[j][z]] == 0)
p[s[j][z]] = j;
else if(p[s[j][z]] != j)
p[s[j][z]] = 1e6;
vis[i][s[j][z]] = 1;
}
if(ok[j][z]) lst = z;
}
}
for(j=1; j<=n; j++)
{
for(int z=1; z<=li[j]; z++)
{
if(p[s[j][z]] && p[s[j][z]] != j)
ok[j][z] = 1;
else
ok[j][z] = 0;
}
}
}
for(i=1; i<=q; i++)
{
if(vis[dat[i].r][dat[i].c])
cout<<1<<endl;
else
cout<<0<<endl;
}
}
return 0;
}