Skip to content

Commit ca6bbcf

Browse files
authored
Create D - Happy Birthday! 2(1)
1 parent 03c10fe commit ca6bbcf

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

bitmask/D - Happy Birthday! 2(1)

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

0 commit comments

Comments
 (0)