QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#802710 | #9870. Items | ucup-team5243# | RE | 0ms | 3704kb | C++17 | 2.3kb | 2024-12-07 14:28:52 | 2024-12-07 14:28:56 |
Judging History
answer
#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;
#include <type_traits>
namespace nachia{
template<class TargetInt, TargetInt Max, TargetInt Min = TargetInt(1), class Callback>
void CallWithConstexprFittingInt(TargetInt val, const Callback& callback){
if(Max / 2 < val || Max / 2 < Min){ callback(std::integral_constant<TargetInt, Max>()); return; }
CallWithConstexprFittingInt<TargetInt, Max / 2, Min, Callback>(val, callback);
}
}
void testcase(){
i64 N, M; cin >> N >> M;
nachia::CallWithConstexprFittingInt<i64, 1<<20>(N, [N,M](auto Z){
using Bitset = bitset<Z()*2>;
i64 z = Z();
auto conv = [&](Bitset& l, Bitset& r, Bitset& d) -> void {
for(i64 i=0; i<N; i++) if(r.test(i)){
d |= l >> (N-i);
}
for(i64 i=N; i<=N*2; i++) if(r.test(i)){
d |= l << (i-N);
}
//cout << "L = " << l << endl;
//cout << "R = " << r << endl;
//cout << "D = " << d << endl;
};
auto powb = [&](Bitset& a, i64 p){
Bitset q; q.set(N);
for(i64 t=17; t>=0; t--){
Bitset r; conv(q, q, r);
if(p & 1 << t){
q = Bitset();
conv(r, a, q);
} else {
q = r;
}
}
return q;
};
Bitset A;
i64 F = M / N;
//cout << "F = " << F << endl;
rep(i,N){
i64 a; cin >> a;
A.set(a+N-F);
}
// cout << A << endl;
auto x = powb(A, N);
// cout << x << endl;
bool ans = x.test(M%N + N);
cout << (ans ? "Yes\n" : "No\n");
});
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
i64 T; cin >> T;
rep(t,T) testcase();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3704kb
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
Runtime Error
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...