Skip to content

Commit 03c10fe

Browse files
authored
Create D - Happy Birthday! 2
1 parent 409661b commit 03c10fe

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed

bitmask/D - Happy Birthday! 2

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
//Author: Fuadul Hasan([email protected])
2+
//BSMRSTU,Gopalganj
3+
//#include<bits/stdc++.h>
4+
#define _USE_MATH_DEFINES
5+
#include <set>
6+
#include <map>
7+
#include <list>
8+
#include <queue>
9+
#include <stack>
10+
#include <cmath>
11+
#include <ctime>
12+
#include <cstdio>
13+
#include <string>
14+
#include <vector>
15+
#include <bitset>
16+
#include <random>
17+
#include <cassert>
18+
#include <cstring>
19+
#include <sstream>
20+
#include <complex>
21+
#include <numeric>
22+
#include <iostream>
23+
#include <algorithm>
24+
#include <functional>
25+
#include <unordered_set>
26+
#include <unordered_map>
27+
using namespace std;
28+
29+
//debug..........
30+
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
31+
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
32+
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
33+
34+
//............ignore it..................//
35+
#define F first
36+
#define S second
37+
#define Pi atan(1)*4
38+
#define mp make_pair
39+
#define pb push_back
40+
const int M = 1e9 + 7;
41+
#define ld long double
42+
#define ll long long int
43+
#define happy cin.tie(0);
44+
#define point(x) cout<<fixed<<setprecision(x)
45+
int length(string s){return (int)s.size();}
46+
#define mem(a) memset(a , 0 ,sizeof a)
47+
#define memn(a) memset(a , -1 ,sizeof a)
48+
#define coding ios::sync_with_stdio(false);
49+
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
50+
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;
51+
52+
int length(long long x){int l = 0;for(long long i=x;i;i/=10)l++;return l;}
53+
int dx[8]= {1,0,-1,0,-1,-1,1,1};
54+
int dy[8]= {0,1,0,-1,-1,1,-1,1};
55+
56+
#define rep(i,b,e) for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e)) ; i += 1 - 2 * ((b) > (e)))
57+
58+
long long Inv_pow(long long a,long long n){ll res = 1;while(n){if(n&1) res = ((res%M)*(a%M))%M;a = ((a%M)*(a%M))%M;n>>=1;}return res%M;}
59+
// suffix_prefix....
60+
std::vector<ll> prefix_sum(ll a[], int n){std::vector<ll> prf(n,0);for(int i=0;i<n;i++){
61+
if(i == 0){prf[i] = a[i];}else{prf[i] = prf[i-1]+a[i];}}return prf;}
62+
std::vector<ll> suffix_sum(ll a[], int n){std::vector<ll>suf(n,0);for(int i=n-1;i>=0;i--){
63+
if(i == n-1){suf[i] = a[i];}else{suf[i] = suf[i+1]+a[i];}}return suf;}
64+
65+
long long Lcm(long long a,long long b){return (((a)*(b)))/__gcd(a,b);}
66+
67+
#define Test cout<<"Case #"<<tc++<<": ";
68+
int tc = 1;
69+
70+
inline void read(std::vector<int> &v){for(int i=0;i<(int)v.size();i++){cin>>(v[i]);}}
71+
inline void readl(std::vector<ll> &v){for(int i=0;i<(int)v.size();i++){cin>>(v[i]);}}
72+
73+
template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
74+
template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
75+
76+
inline void read(int v[],int n){for(int i=0;i<n;i++){cin>>(v[i]);}}
77+
inline void readl(ll v[],int n){for(int i=0;i<n;i++){cin>>(v[i]);}}
78+
79+
inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
80+
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
81+
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}
82+
83+
#define pr pair<int, int>
84+
#define vpr vector<pr>
85+
#define vi std::vector<int>
86+
#define vll std::vector<ll>
87+
#define all(n) n.begin(),n.end()
88+
89+
90+
const int Inf = (int)2e9 + 5;
91+
const ll Lnf = (ll)2e18 + 5;
92+
const int N = 5e5 + 5;
93+
const int NN = 1e6 + 5;
94+
95+
void output(std::vector<int> a){
96+
cout<<a.size()<<" ";
97+
for(int i: a){
98+
cout<<i<<" ";
99+
}cout<<endl;
100+
}
101+
102+
int solve()
103+
{
104+
105+
//Test
106+
107+
int n;
108+
cin>>n;
109+
110+
std::vector<int> a(n);
111+
for(auto &x: a)cin>>x;
112+
113+
std::vector<std::vector<int>> bk(200, std::vector<int>(0));
114+
115+
int cnt = min(8,n);
116+
117+
for(int i=1;i<(1<<cnt);i++){
118+
int sig = 0;
119+
std::vector<int> s;
120+
for(int j=0;j<cnt;j++){
121+
if(i&(1<<j)){
122+
s.push_back(j+1);
123+
sig += a[j];
124+
sig %= 200;
125+
}
126+
}
127+
if(bk[sig].size()!= 0){
128+
cout<<"Yes"<<endl;
129+
output(bk[sig]);
130+
output(s);
131+
return 0;
132+
}else{
133+
bk[sig] = s;
134+
}
135+
}
136+
cout<<"No"<<endl;
137+
138+
139+
return 0;
140+
//error();
141+
}
142+
int main(){
143+
144+
happy coding
145+
int test = 1;
146+
//cin>>test;
147+
while (test--)solve();return 0;
148+
}
149+
150+
/*
151+
Age doesn't make you mature Responsibility makes.
152+
*/

0 commit comments

Comments
 (0)