1010
签到题,模拟一下
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int N=2e5+10;
const int mod=998244353;
void solve()
{
int n,m;
cin>>n;
vector<int>cnt(7);
int tot=0;
for(int i=1;i<=n;i++){
int x;
cin>>x;
if(!cnt[x])tot++;
cnt[x]++;
}
for(int i=1;i<=6;i++)cnt[i]=0;
for(int i=1;i<=n;i++){
int x;
cin>>x;
if(!cnt[x])tot++;
cnt[x]++;
}
if(tot==2*n){
cout<<"Just a game of chance.\n";
}else cout<<"Win!\n";
}
signed main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int t=1;
cin>>t;
while(t--)solve();
}
1012
bitset确实好用,用bitset节省空间和时间,进行模拟暴力
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 200005;
struct node{
int l,r;
}qj[N];
bool cmp(node x,node y) {
if(x.l != y.l) return x.l<y.l;
else return x.r > y.r;
}
bitset<200001> ma[20004];
void solve() {
int n,m;
cin>>n>>m;
int maxx=0;
for(int i=1;i<=n;i++) {
cin>>qj[i].l>>qj[i].r;
maxx=max(qj[i].r,maxx);
}
ll ans = 20000*20000;
if(n<=m) {
cout<<maxx<<endl;
return ;
}
int rmax = 0,fmax=0;
sort(qj+1,qj+1+n,cmp);
int minn=1<<29,mink=0;
for(int i=1;i<=n;i++) {
bool z=false;
for(int j=1;j<=m;j++) {
bool ok = 1;
for(int k=qj[i].l;k<=qj[i].r;k++) {
int temp = qj[i].l ;
if(ma[m][k] == 1 ) {
ok = false;
temp = k;
}
if(temp<minn) {
minn = temp;
mink = j;
}
//minn = min (temp,minn);
}
if(ok) {
for(int k=qj[i].l;k<=qj[i].r;k++) {
ma[m][k] = 1;
rmax = max(rmax,k);
}
z=1;
}
}
if(!z) {
for(int k=qj[i].l;k<=qj[i].r;k++) {
ma[mink][k] = 1;
fmax = max(k,fmax);
}
}
}
ans=max(rmax,fmax);
cout<<ans<<endl;
}
int main() {
int t;
cin>>t;
while(t--) {
solve();
}
return 0;
}