File tree 1 file changed +66
-0
lines changed
1 file changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #include < bits/extc++.h>
3
+ #define ms (x,v ) memset((x),v,sizeof (x))
4
+ #define INF 0x3f3f3f3f
5
+ using namespace std ;
6
+ // using namespace __gnu_pbds;
7
+
8
+ const int MAXN = 100 +10 ;
9
+ typedef long long LL;
10
+
11
+
12
+ void solve (){
13
+ vector<LL> A (9 );
14
+ for (int i=0 ; i<A.size () ; ++i)
15
+ {
16
+ cin >> A[i];
17
+ if (A[i] > 20 )
18
+ A[i] = 20 + (A[i] & 1 );
19
+ }
20
+
21
+ vector<vector<set<int >> > dp (10 ,vector<set<int >>(11 ));
22
+
23
+ for (int i=0 ; i<A.size () ; ++i){
24
+ for (int k = 0 ; k<=A[i]; ++k){
25
+ int d = 2 * k * (i+1 ) % 11 ;
26
+ for (int j=0 ; j<11 ; ++j){
27
+ int v = (d +j) % 11 ;
28
+ if (dp[i][j].empty ())dp[i+1 ][d].insert (k);
29
+ else {
30
+ for (const auto & e : dp[i][j]){
31
+ dp[i+1 ][v].insert ((e + k));
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ LL sum =0 ;
38
+ LL x = 0 ;
39
+ for (int i=0 ; i<A.size () ;++i){
40
+ x = (x + A[i] * (i+1 )) % 11 ;
41
+ sum = (sum + A[i]);
42
+ }
43
+ if (dp[9 ][x].count ((sum)/2 ) )
44
+ cout << " YES\n " ;
45
+ else cout << " NO\n " ;
46
+ }
47
+
48
+
49
+
50
+
51
+
52
+ int main (){
53
+ ios :: sync_with_stdio (0 );
54
+ cin.tie (0 );
55
+ // cout.tie(0);
56
+ std::cout.precision (10 );
57
+ std::cout.setf ( std::ios::fixed, std:: ios::floatfield );
58
+ int T;
59
+ cin >> T;
60
+ for (int tt =1 ; tt <=T ; ++tt)
61
+ {
62
+ cout << " Case #" << tt << " : " ;
63
+ solve ();
64
+ }
65
+ return 0 ;
66
+ }
You can’t perform that action at this time.
0 commit comments