QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#805675 | #9870. Items | ucup-team135# | WA | 23ms | 3588kb | C++20 | 3.5kb | 2024-12-08 17:53:46 | 2024-12-08 17:53:50 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <fstream>
#include <array>
#include <functional>
#include <stack>
#include <memory>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define x first
#define y second
#define Time (double)clock()/CLOCKS_PER_SEC
#define munq(a) sort(all(a)); a.resize(unique(all(a))-a.begin())
#define sz(a) ((int)a.size())
int p=998244353;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*1LL*u)%p;} else {int u=po(a,b-1);return (a*1LL*u)%p;}}
int inv(int x) {return po(x,p-2);}
mt19937 rnd;
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)
#define debugv(v) do {cout<< #v <<" : {"; for(int izxc=0;izxc<v.size();++izxc) {cout << v[izxc];if(izxc+1!=v.size()) cout << ","; }cout <<"}"<< endl;} while(0)
#else
#define debug(...)
#define debugv(v)
#endif
#define lob(a,x) lower_bound(all(a),x)
#define upb(a,x) upper_bound(all(a),x)
const int maxn=1e5+5;
int di[maxn];const int inf=1e12;
bitset<maxn> unuse;
bitset<maxn> moves;
vector<int> get(bitset<maxn> &b)
{
vector<int> res;
int cur=b._Find_first();
res.app(cur);
while(cur<maxn)
{
cur=b._Find_next(cur);
res.app(cur);
}
while(!res.empty() && res.back()>=maxn) {res.pop_back();}
return res;
}
bool check(vector<int> a,int n,int m)
{
if(a.size()==1 && a[0]==0) {return m==0;}
if(m<0) {return false;}
int ma=a.back();
di[0]=0;for(int i=1;i<ma;++i) {di[i]=inf;}
unuse=0;moves=0;
for(int i=1;i<ma;++i) {unuse[i]=1;}
for(int b:a) {if(b!=0 && b<ma) moves[b]=1;}
set<int> cur={0},al;
set<int> nx;
while(!cur.empty())
{
for(int x:cur)
{
al.insert(x);
bitset<maxn> h=(unuse>>x) & moves;
vector<int> vv=get(h);
for(int m:vv)
{
cur.insert(x+m);
di[x+m]=di[x];
unuse[x+m]=0;
}
}
for(int x:al)
{
bitset<maxn> h=(unuse<<(ma-x)) & moves;
vector<int> vv=get(h);
for(int m:vv)
{
nx.insert(x+m-ma);
di[x+m-ma]=di[x];
unuse[x+m-ma]=0;
}
}
cur=nx;al.clear();nx.clear();
}
int mim=di[m%ma]*ma+(m%ma);
return mim<=m;
}
int32_t main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t--)
{
int n,m;cin>>n>>m;
vector<int> a(n);
for(int i=0;i<n;++i) {cin>>a[i];}
munq(a);
int mi=a[0];
m-=mi*n;for(int &x:a) {x-=mi;}
if(!check(a,n,m))
{
puts("No");continue;
}
int ma=a.back();
for(int &x:a) {x=ma-x;} sort(all(a));
if(!check(a,n,ma*n-m))
{
puts("No");continue;
}
puts("Yes");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
input:
4 5 25 0 0 0 0 5 5 11 4 4 4 5 5 5 0 1 2 3 4 5 5 25 0 1 2 3 4
output:
Yes No No No
result:
ok 4 token(s): yes count is 1, no count is 3
Test #2:
score: -100
Wrong Answer
time: 23ms
memory: 3576kb
input:
1314 1 0 0 1 0 1 1 1 0 1 1 1 2 0 0 0 2 0 0 1 2 0 0 2 2 0 1 0 2 0 1 1 2 0 1 2 2 0 2 0 2 0 2 1 2 0 2 2 2 1 0 0 2 1 0 1 2 1 0 2 2 1 1 0 2 1 1 1 2 1 1 2 2 1 2 0 2 1 2 1 2 1 2 2 2 2 0 0 2 2 0 1 2 2 0 2 2 2 1 0 2 2 1 1 2 2 1 2 2 2 2 0 2 2 2 1 2 2 2 2 2 3 0 0 2 3 0 1 2 3 0 2 2 3 1 0 2 3 1 1 2 3 1 2 2 3 2 0...
output:
Yes No No Yes Yes Yes Yes Yes No No Yes No No No Yes No Yes No No No No No No Yes Yes Yes Yes Yes Yes Yes No No No No No No Yes No Yes No No No Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No No Yes No No No Yes No No No Yes Yes Yes...
result:
wrong answer expected NO, found YES [125th token]