prompt
string
response
string
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#pragma GCC optimize ("O3") #include <iostream> #include <iomanip> #include <istream> #include <ostream> #include <sstream> #include <iterator> #include <vector> #include <algorithm> #include <queue> #include <deque> #include <list> #include <stack> #include <map> #include <unordered_map> #include <set> #include <bitse...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <numeric> #include <cstdlib> #include <climits> #include <cmath> #include <cstdio> #include <cfloat> #include <map> #include <utility> #include <set> #include <memory> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <memory.h> #includ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #pragma comment (linker, "/STACK:526000000") #include "bits/stdc++.h" using namespace std; typedef string::const_iterator State; #define eps 1e-11L #define MAX_MOD 1000000007LL #define GYAKU 500000004LL #define MOD 998244353LL #define seg_size 262144 #defin...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static IO io = new IO(); public static void main(String[] args) { while(solve()); io.flush(); } stat...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<cstdio> #include<cstring> #include<algorithm> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int INF=1<<29; int m,n,obj[128]; int dp[1<<11][1<<11]; int dfs(int asked,int S){ // asked : すでに質問した特徴, S : 知りたい物体の特徴 ( 判明した bit は 0 or 1, 不明な bit は 0 ) int cnt=0; // 今わかっている情報と矛盾しない候補の個数 rep(...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
from collections import Counter while True: m, n = (int(s) for s in input().split()) if not m: break objects = [int(input(), 2) for i in range(n)] dp = [bytearray(1 << m) for i in range(1 << m)] bits = [1 << i for i in range(m)] for asked in reversed(range((1 << m) - 1)): for ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include "bits/stdc++.h" #include <sys/timeb.h> #include <fstream> using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--) #define reprev(i,n) replrev(i,0,n) #define repi(itr,ds) for(auto itr = ds.begin(); it...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; #define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl #define repi(i,a,b) for(int i=int(a);i<int(b);i++) #define peri(i,a,b) for(int i=int(b);i-->int(a);) #define rep(i,n) repi(i,0,n) #define per(i,n) peri(i,0,n) #define all(c) begin(c),end(c) #define mp make_pair #define mt make...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; int n,m; string obj[222]; unordered_map<int,int> memo; int rec(int state){ if(memo.count(state))return memo[state]; int cnt = 0, tmp = state; vector<int> col(m); rep(i,m){ col[i] = tmp%3; tmp/=3; } rep(i,n){ bool...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> using namespace std; int n,m; int t[128]; map<vector<int>,int> mp; int rec(vector<int> v){ if(v.size()<=1)return 0; if(mp.count(v)>0)return mp[v]; int res=1e9; for(int i=0;i<n;i++){ vector<int> A,B; for(int j=0;j<(int)v.size();j++){ int id=v[j]; if(t[id]>>i&1)A.pus...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
import java.util.*; public class Main { private static Scanner scanner; public static int[] inputIntArray(int n) { int[] res = new int[n]; for (int i = 0; i < n; ++i) { res[i] = scanner.nextInt(); } return res; } // public static String[] <T> ToStringArray...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vector<int>>; using vll = vector<ll>; using vvll = vector<vector<ll>>; const double eps = 1e-10; const ll MOD = 1000000007; const int INF = 1000000000; const l...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int m, n; int rec(vector<int> rest, map<vector<int>, int>& memo) { if(memo.count(rest) == 1) { return memo[rest]; } int& res = memo[rest]; if(rest.size() <= 1) { return res = 0; } res = m; for(int i=0; i<m; ++i) { vector...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> #include <queue> #include <map> #include <set> #include <vector> #include <string> #include <stack> #include <bitset> #define INF 0x3f3f3f3f #define eps 1e-8 #define FI first #define SE second using namespa...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <algorithm> #include <iostream> #include <vector> #include <map> #include <numeric> using namespace std; int m; vector<vector<bool>> obj; map<vector<int>, int> memo; int dfs(vector<int>& set) { if (set.size() == 1) return 0; if (memo[set]) return memo[set]; memo[set] = m; for (int f = 0; f < ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> #include <cstdio> using namespace std; map<set<int>,int>memo; int M,N; vector<string>v; int dfs(set<int> &t){ if(t.size()==1)return 0; if(memo.find(t)!=memo.end())return memo[t]; int r=1<<30; for(int j=0;j<M;...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<sstream> #include<algorithm> #include<set> #include<map> #include<queue> #include<complex> #include<cstdio> #include<cstdlib> #include<cstring> #include<cassert> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define mp make_pair #define pb push_back #define...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<cstdio> #include<cstring> #include<vector> #include<queue> #include<algorithm> #include<cmath> #include<climits> #include<string> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define reg(i,a,b) for(int i=(a);i<=(b);i++) #define irep(i,n) for(int i=((int)(n))-1;i>=0;i--) #define ireg(i,a,b) for(...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) #define MAX 130 using namespace std; const int IINF = INT_MAX; int m,n; string G[MAX]; map<deque<int>,int> memo; int dfs(const deque<int> &obj){ if( obj.size() <= 1 ) return 0; if( memo.find(obj) != memo.end() ) return m...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
import java.io.*; import java.util.*; public class Main { int M, N; BitSet[] bits; HashMap<BitSet, Integer> memo = new HashMap<>(); public int dfs(BitSet group){ if(group.cardinality() < 2) return 0; if(memo.containsKey(group)){ return memo.get(group); } int ans = 100000; for(int i = 0; ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#define _USE_MATH_DEFINES #define INF 0x3f3f3f3f #include <cstdio> #include <iostream> #include <sstream> #include <cmath> #include <cstdlib> #include <algorithm> #include <queue> #include <stack> #include <limits> #include <map> #include <string> #include <cstring> #include <set> #include <deque> #include <bitset> #in...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; } template<c...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> using namespace std; int m, n; string s[128]; map<vector<int>,int> memo; int dfs(vector<int> &idx){ if( idx.size() <= 1 ) return 0; if( memo.count(idx) ) return memo[idx]; int res = 12; for(int i=0;i<m;i++){ vector<int> idx0, idx1; for(int j : idx){ if(...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <string> #include <vector> #include <map> #include <algorithm> #include <cstdio> using namespace std; map<__uint128_t,int>memo; int M,N; vector<string>v; int dfs(__uint128_t t){ int c=0; for(int i=0;i<N;i++){ if(t&(__uint128_t)(1)<<i)c++; } if(c==1)return 0; if(memo.find(t)!=memo.en...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<algorithm> #include<vector> #include<stack> #include<map> #include<set> #include<queue> #include<cstdio> #include<climits> #include<cmath> #include<cstring> #include<string> #include<sstream> #include<numeric> #include<cassert> #define f first #define s second #define mp make_pair #define ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) using namespace std; typedef long long ll; int main(void) { ll M, N; while(cin >> M >> N, N && M) { vector<string> S(N); REP(i, 0, N) cin >> S[i]; const ll INF = 1LL << 50; ll m2 = M * 2; vector<ll> dp(1LL <<...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; const ll MOD = 1000000007; int m, n; vector<vector<int>> feats; map<vector<int>, int> memo; vector<int> fix; int dfs(){ if(memo.find(fix) != memo.end()) return memo[fix]; int num = 0; for(int i=0;i<n;i++){ ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> using namespace std; const int MAXN=130; const int MAXB=11; const int MAXS=(1<<MAXB)+5; int m, n; struct data{ int ans; }obj[MAXN]; short dp[MAXS][MAXS]; int dfs(int state, int now){ short &ret=dp[state][now]; if(ret!=-1) return ret; int cnt=0; for(int i=0; i<n; i++){ ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep(i,n) repl(i,0,n) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #defi...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> using namespace std; #define int long long typedef vector<int>vint; typedef pair<int,int>pint; typedef vector<pint>vpint; #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define all(v) (v).begin(),(v).end() #define each(it,v) for(__typeof((v).begin()) it=(v)...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; #define int long long #define REP(i, n) for (int i = 0, loop##i = (int)(n); i < loop##i; ++i) #define SZ(x) ((int)(x.size())) #define ALL(x) x.begin(), x.end() #define BIN(w, x) bitset<w>(x) int m, n; int memo[1 << 11][1 << 11]; int bits[200]; int rec(int used, int yesno) ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <stdio.h> #include <cmath> #include <algorithm> #include <cfloat> #include <stack> #include <queue> #include <vector> #include <string> #include <iostream> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define MOD 1000000007 #define EPS 0.000000001 using namespace std...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solver(); } int[][] memo; int[] ans; int n, m; int rep(int masked, int answer) { if (memo[masked][answer] != -1) { return memo[masked][answer]; } int count = 0; for (int i = 0...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <string> #include <vector> #include <map> #include <numeric> #include <algorithm> #include <cstdio> using namespace std; map<vector<int>,int>memo; int M,N; vector<string>*vp; int dfs(vector<int> &t){ if(t.size()==1)return 0; if(memo.find(t)!=memo.end())return memo[t]; int r=1<<30; for(...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<vector> #include<string> #include<map> #include<algorithm> using namespace std; typedef vector<int> vi; int M, N; int character[150][15]; map<vi, int> mp; int dfs(vi S) { if (S.size() <= 1) return 0; int& ret = mp[S]; if (ret > 0) return ret; ret = M; for (int i = 0; i < M; i++) { v...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <complex> #include <queue> #include <map> #include <set> #include <cstring> #include <cstdlib> #include <string> #include <cmath> #include <cassert> #include <stack> #include <bitset> using namespace std; #define REP(i,n) for(int i=0...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #define rep(i,n) for(int i = 0;i< n;i++) #define INF 200 typedef long long int ll; using namespace std; int m,n; int pow3[12]; int obj[200]; int dp[177150];//?????¢?´¢-1,?????¨?????????-2,?????????????????¢?´¢?????° int fact(int num,int i){ return (num/pow3[i])%3; } void dfs(int que){ if(d...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> #define FOR(i,k,n) for(int i=(k);i<(int)(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(x) begin(x),end(x) using namespace std; int solve(map<vector<vector<bool>>, int>& memo, const vector<vector<bool>> &v, const set<int>& s) { if (v.size() <= 1) return 0; if (memo.find(v) != end(memo)) ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (int) (n); i++) #define reps(i, n) for (int i = 1; i <= (int) (n); i++) #define all(x) (x).begin(), (x).end() #define uniq(x) (x).erase(unique(all(x)), (x).end())) #define bit(n) (1LL << (n)) #define cdiv(a, b) ((...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
from collections import Counter import sys def solve(): readline = sys.stdin.buffer.readline write = sys.stdout.buffer.write M, N = map(int, readline().split()) if M == N == 0: return False B = [int(readline(), 2) for i in range(N)] memo = {} def dfs(s, t): key = (s, t) ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <vector> #include <unordered_map> #include <bitset> using namespace std; typedef bitset<128> bit; int M, N; vector<string> v; unordered_map<bit, int> memo; int dfs(bit t){ if(memo.find(t) != memo.end())return memo[t]; if(t.count() == 1)return 0; int r = 1 << 30; for(int j=0;j<M;j++){...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; #define rep(i,n) for(auto i=0*(n);i<(n);++i) int main(){ while(true){ ll m, n; cin >> m >> n; if(m==0 && n == 0) break; vector<string> a(n); rep(i,n) cin >> a[i]; u...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <set> #include <map> using namespace std; int M,N; map<pair<set<int>,set<int>>,int> m; char F[129][12]; int dfs(set<int> ob,set<int> fe){ if(ob.size()<=1) return (M-(int) fe.size()); if(m.count({ob,fe})) return m[{ob,fe}]; int res = 1e9; set<int> fe2 = fe; for(auto x:f...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(long long i = 0; i < (long long)(n); i++) template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; static co...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
/* x日間悩み、 動的計画法でやろうということを思いついた。 数学的に解が得られる方法は複数ありうる。 しかし、0 < m \leq 11 and 0 < n \leq 128 という制約の中で 制限に引っかからなそうなものとなると、状態の持ち方が限られる。 たとえば自然な発想として、 「n個のonjectの各部分集合を状態として持ち、それを類別するために必要な最小の 質問回数」を配列で持とうとするものが考えられる。 しかし2^{128}個のintはメモリの上においておくのは無理である。 よく考えてみると相当無駄がある。質問はm \leq 11個しかない ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cc...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef pair<ll,P> PP; const long long int MOD = 1000000007; const int INF = 1000000000; int n, m; int x[128][11]; map<string,int> dp; int dfs(string str){ //cout << str << endl; ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> using namespace std; const int INF=1000; int powpow(int x,int k){ int res=1; for(int i=0;i<k;i++) res*=x; return res; } int solve(int m,int n){ vector<vector<int>> obj(n,vector<int>(m)); for(int i=0;i<n;i++){ string s; cin>>s; for(int j=0;j<m;j++){ ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
from collections import Counter while True: m, n = (int(s) for s in input().split()) if not m: break objects = [int(input(), 2) for i in range(n)] dp = [bytearray(1 << m) for i in range(1 << m)] bits = [1 << i for i in range(m)] for mask in reversed(range((1 << m) - 1)): for m...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> using namespace std; #define int long long map<int,int> dp[1<<12]; int m,n; string s[200]; int dfs(int b,int r){ if(dp[b].count(r)) return dp[b][r]; int res=m; int cnt=0; for(int i=0;i<n;i++){ int f=1; for(int j=0;j<m;j++) if(b>>j&1) f&=((s[i][j]=='1')==(r>>j&1)); cnt+=...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int hoge(int x, int y) { int r = 1; for(int i = 0; i < y; ++i) r *= x; return r; } int calc(int state, int m, vector<int> &a, vector<int> &memo) { if(memo[state] != -1) return memo[state]; int n = a.size(); int ans = 0, filter =...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> #define ll long long #define INF (1LL << 63) #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define all(v) (v).beg...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define EXIST(s,e) ((s).find(e)!=(s).end()) #define FOR(i,a,b) for(int i...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<string> #include<map> #include<vector> #include<algorithm> using namespace std; typedef vector<int> vi; int m,n; string obj[130]; map<vi, int> mp; int dfs(vi &c){ if(c.size()<=1) return 0; //分かった int& x = mp[c]; if(x) return x; //探索済み。その他、デフォは0 x = m; for(int i=0;i<...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int w; map<vector<int>,int> mem; int dfs(vector<int> &A){ int n = A.size(); if(n<=1) return 0; if(mem.count(A)) return mem[A]; int res = A.size()-1; for(int i=0;i<w;i++){ vector<int> T,F; for(int j=0;j<n;j++) (A[j]>>i&1)? T.push_back(A[j]) : F.push_b...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <sstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <climits> #include <cfloat> using namespace std; int m, n; ve...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <cstdio> #include <cstring> #include <queue> #include <vector> #include <iostream> #include <string> #define INF 1<<10 using namespace std; int n,m; int dp[1<<12][1<<12]; int data[150]; vector<int> dif; int memo(int used,int yn){ if(dp[used][yn]!=INF)return dp[used][yn]; int cnt=0; for(int i=0;i<n;i++){ ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; const int inf = 1e9; bool issame(string &a, string &b){ for(int i=0; i<(int)a.length(); i++){ if(a[i]!='x' && b[i]!='x' && a[i]!=b[i]){ return false; } } return true; } int solve(string &str, vector<string> &s, ma...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i) const int inf = 1<<30; using vs = vector<string>; template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;} int n, m; vs info; map<string, int> memo; int rec(string s){ int c = 0; ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int n; int m; int lim; int ans; int as[1145]; map<vector<int>, int> memo; int dfs(vector<int> &vi) { int ret = m; if (memo.count(vi)) return memo[vi]; if (vi.size() <= 1) return 0; for (int i=0; i<m; i++) { vector<int> a, b; for (int idx : vi) { if ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
// // main.cpp // H // // Created by 譚?髣サ霎セ on 15/2/24. // Copyright (c) 2015蟷エ 譚?髣サ霎セ. All rights reserved. // #include <iostream> #include <cstdio> #include <cstring> int n,m,a,b[130],dp[2100][2100],v[15]; int dfs(int s1,int s2){ if(dp[s1][s2]!=dp[2099][2099])return dp[s1][s2]; int cnt=0; for(int i=...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
// Enjoy your stay. #include <bits/stdc++.h> #define EPS 1e-9 #define INF 1070000000LL #define MOD 1000000007LL #define fir first #define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++) #define ite iterator #define mp make_pair #define mt make_tuple #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int func(vector<bitset<11>> &v, unordered_map<bitset<128>, int> &mp, bitset<128> x, int n, int m){ if(mp.count(x)) return mp[x]; if(x.count() == 1) return mp[x] = 0; int res = 1e9; for(int i=0; i<m; ++i){ bitset<128> y = x, z = x; for(int j=0; j<n; ++j){ if(v[j]...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <cstring> #include <climits> using namespace std; int w, h; short dp[1<<11][1<<11]; int bit[200]; bool t[200][200]; int solve(int q, int a){ if(dp[q][a] != -1) return dp[q][a]; int cnt = 0; for(int i = 0; i < h; i++){ if((bit[i] & q) == a){ cnt++; if(cnt > 1) break...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <array> #include <algorithm> #include <bitset> #include <cstring> #include <cstdlib> #include <iostream> #include <vector> using namespace std; template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; } constexpr int MAX_M = 11; int m, n; int memo[1 << MAX_M][1 << MAX_M]; int dfs(int used, ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int M, N; vector<int> objects; int memo[1<<11][1<<11]; int to_int(string s){ int res = 0; for(int i=0; i<s.size(); i++){ res = res*2 + (s[i] == '1'); } return res; } int dfs(int s, int ys){ if(memo[s][ys] >= 0) return memo[s][ys]; int...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
import java.util.*; public class Main { static int minmin; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int m = sc.nextInt(); int n = sc.nextInt(); if (m == 0 && n == 0) break; List<boolean[]>...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, n) for (int i = (n); i >= 0; --i) #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define FORR(i, m, n) for (int i = (m); i >= (n); --i) #define equals(a, b) (fabs((a) - (b)) < EPS) using namespace std; typedef long long ll; t...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; #define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++) #define REP(i,n) FOR(i,0,n) #define ALL(a) a.begin(), a.end() #define MS(m,v) memset(m,v,sizeof(m)) #define D10 fixed<<setprecision(10) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; map< vector< int >, int > dp; int M, N; int bit[128]; int rec(vector< int > idx, int v) { if(dp.count(idx)) return (dp[idx]); if(idx.size() <= 1) return (0); int ret = 1333; for(int i = 0; i < M; i++) { if((v >> i) & 1) continue; vector< int > latte, mal...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <vector> #include <queue> #include <stack> #include <map> #include <algorithm> using namespace std; int M,N; char s[135][15]; map < pair< vector<int>,int > ,int> MAP; int flere(vector <int> list,int level,int used){ int i,j,k=M; i...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int m, n; int ans[150]; int dp[2050][2050]; // S?????????????????£?????? using Set = bitset<12>; int rec(int asked, int answer){ // ??????????????????aked???answer??¨?????????????????? int &res = dp[asked][answer]; if(res != -1) return res; res = m; int ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
import java.util.ArrayList; import java.util.Scanner; public class Main { static int m, n; static ArrayList<String> data; static int[][] memo; static int toInt(boolean[] bool) { int ret = 0; for (boolean b: bool) { ret *= 2; if (b) ret += 1; } re...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<cstdio> #include<vector> #include<string> #include<cstring> #include<functional> #include<queue> #include <iomanip> #include<map> #include<limits> #include<cmath> #include<algorithm> #include<bitset> #include<utility> #include<complex> #include<cstdlib> #include<set> #include<cctype> #defin...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int m, n; int mem[177147]; int rec(const vector<bitset<11>>& v, int S = 0){ if(v.size() <= 1) return 0; int& res = mem[S]; if(res != -1) return res; res = m; for(int i = 0;i < m;++i){ if(S/(int)pow(3, i)%3 != 0) continue; vector<bitse...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <string> #include <vector> #include <map> #include <algorithm> #include <cstdio> using namespace std; map<__uint128_t,int>memo; int M,N; vector<string>v; int dfs(__uint128_t t){ if(memo.find(t)!=memo.end())return memo[t]; int c=0; for(int i=0;i<N;i++){ if(t&(__uint128_t)(1)<<i)c++; }...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<string.h> #include<vector> #include<algorithm> #include<set> #include<map> #include<queue> #include<stack> #include<math.h> #include<climits> using namespace std; typedef unsigned long long ll; const int mod=1000000007; int m,n; string g[129]; map<vector<string>,int>ma; int dfs(vector<st...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <set> #include <map> using namespace std; int m,n; int calc(vector<bool> &p,vector<string>&v,map<vector<bool>,int> &mp){ if(mp.find(p)!=mp.end())return mp[p]; int mi=10000; for(int i=0;i<m;i++){ vector<bool>q(n),r...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
// 2009ツアツジツアツ地ツ凝ヲツ予ツ選 H : Twenty Questions #include <iostream> #include <fstream> #include <vector> #include <string> #include <map> using namespace std; map<pair<vector<int>, int>, int> mp; string qes[128]; int search(vector<int> &vi, int depth, int used, int m, int n){ if(mp.count(make_pair(vi, used))) return mp...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> #define r(i,n) for(int i=0;i<n;i++) using namespace std; int n,m,A[128]; map<set<int>,int>M; int dfs(set<int> st){ if(st.size()<=1)return 0; if(M.count(st))return M[st]; int res=99; r(i,m){ set<int>S1,S2; for(set<int>::iterator it=st.begin();it!=st.end();it++){ ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> usi...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int solve(vector<int> &v, int m, int asked, int sig, vector<vector<int> > &memo) { int n = v.size(); int res = 128; int count = 0; for (int j = 0; j < n; j++) { if ((v[j] & asked) == (sig & asked)) { ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) //#define int long long #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define all(x) x.begin(), x.end() using pii = pair<int, int>; using ll = long long; bool candiv[202][202]; string ss[202]; int M, N; int dat[150];...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; int n,m; string obj[222]; int memo[200200]; int rec(int state){ if(memo[state]>=0)return memo[state]; int cnt = 0, tmp = state; vector<int> col(m); rep(i,m){ col[i] = tmp%3; tmp/=3; } rep(i,n){ bool f = true; ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxm = 11, maxn = 130; int n, m,f[1 << maxm][1 << maxm], mask[maxn], s[1 << maxm]; int main() { while (scanf("%d%d", &m, &n), m || n) { for (int i = 0; i < n; i++) { char str[12]; ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <set> #include <map> using namespace std; int M,N; map<pair<set<int>,set<int>>,int> m; char F[129][12]; int dfs(set<int> ob,set<int> fe){ if(ob.size()<=1) return (M-(int) fe.size()); if(m.count({ob,fe})) return m[{ob,fe}]; int res = 1e9; set<int> fe2 = fe; for(auto x:f...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <cstdio> #include <vector> #include <algorithm> #include <string> #include <iostream> #include <cstdio> using namespace std; int str2bin(string s) { int res = 0; for(size_t i=0; i<s.size(); i++) { res = res * 2 + (s[i] == '1'); } return res; } const int INF = 1 << 28; int M, N; int dp...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <sstream> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #include <numeric> #include <cctype> #include <tuple> #include <climits> #include <bits...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include "bits/stdc++.h" using namespace std; typedef pair<int, int> P; typedef pair<int, P> E; typedef long long LL; string code[128]; int obj[128]; int m, n; int memo[2048][2048]; int solve(int q, int a) { if (memo[q][a] != -1) return memo[q][a]; int cnt = 0; for (int i = 0; i < n; i++) { if ((obj[i] & q) == a)c...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <iomanip> #include <cmath> #include <cassert> #include <map> #include <set> using namespace std; int n, m; int Q[128]; int dp[1 << 11][1 << 11]; int dfs(int S, int T) { if(dp[S][T] != -1) return dp[S][T]; int cn...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <complex> #include <queue> #include <map> #include <set> #include <cstring> #include <cstdlib> #include <string> #include <cmath> #include <cassert> #include <stack> #include <bitset> using namespace std; #define REP(i,n) for(int i=0...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Random; import java.util.Scanner; import java.util.function.BiFunction; public class Main{ static Scanner scn = new Scanner(System.in); static FastScan...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<bits/stdc++.h> using namespace std; int m,n; string s[130]; map<vector<int>,int> dp; int rec(vector<int> S){ if(S.size()<=1)return 0; if(dp[S]>0)return dp[S]; dp[S]=m; for(int i=0;i<m;i++){ vector<int> ok,ng; for(int j=0;j<S.size();j++){ if(s[S[j]][i]=='1')ok.push_back(S[j]);...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; int m, n; int ans[150]; int dp[2050][2050]; // S?????????????????£?????? using Set = bitset<12>; int rec(int asked, int answer){ // ??????????????????aked???answer??¨?????????????????? int &res = dp[asked][answer]; if(res != -1) return res; res = m; // ...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
from collections import Counter while True: m, n = (int(s) for s in input().split()) if not m: break objs = [int(input(), 2) for i in range(n)] dp = [bytearray(1 << m) for i in range(1 << m)] bits = [1 << i for i in range(m)] for mask in reversed(range((1 << m) - 1)): s = Cou...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include<iostream> #include<vector> #include<cstring> using namespace std; #define REP(i, N) for(int i = 0; i < (int)N; ++i) // 3 ** 11 int N, M; int num[200000]; int dp[200000]; int encode(string s) { int h = 0; for(int i = 0; i < s.size(); i++) { h = h * 3 + s[i] - '0'; } return h; } void decode(int c, stri...
Problem: Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with "yes" or "no". Using those features, we can identify any object from the rest of the objects in the world. In other words, each object can be represented as a fixed-length sequence...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second #define dbg(x) cout<<#x" = "<<((x))<<endl template<class T,class U> ostream& operator<<(ostream& o, const pa...