Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
int N, M, nonzero[256];
vector< char > list;
vector< string > s;
int conv[256], leftConv[256], rightConv[256];
int check() {
int left = 0, right ... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | //=================================
// Created on: 2018/07/04 15:12:12
//=================================
#include <bits/stdc++.h>
using namespace std;
int main()
{
for (int N;;) {
cin >> N;
if (N == 0) { break; }
vector<int> coeff1(10, 0);
vector<int> coeff2(10, 0);
set<int... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #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)... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <map>
using namespace std;
bool used[10];
bool tabu[10];
int keisu[10];
int ans;
int cnt; // 文字数
int n;
void dfs(int k, int sum){
if (k == cnt) {
if (sum == 0) {
ans++;
}
return;
}
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool ng[26];
int ten[8];
int kiyo[26];
vector<char> vc;
int dfs(int i, int used, int sum){
if(i == vc.size()) return sum==0;
int ret = 0;
for(int j = 0; j < 10; j++){
if((used>>j)&1) continue;
if(j == 0 && ng[vc[... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #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)... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL IN... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
int N;
ios::sync_with_stdio(false);
while(cin >> N,N){
vector<string> S(N);
map<char,int> C;
map<char,bool> not_zero;
long long int ans = 0;
for(int i = 0; i < N; ++i){
cin >> S[i]... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | //AC記録用コピペ
//自分のコードは1テストケースファイルあたり10分程度
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3566759#1
#include <bits/stdc++.h>
using namespace std;
int N, Size;
string s[12];
int rec(int idx, int md, int sum, int used, vector< int >& conb) // ??´???, ??°????????????, ?????£?????°???
{
for(int i = 0; i <... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <map>
using namespace std;
bool used[10];
bool tabu[10];
int keisu[10];
int ans;
int cnt; // 文字数
void dfs(int k, int sum){
if (k == cnt) {
if (sum == 0) {
ans++;
}
return;
}
for (i... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 |
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | import java.util.Arrays;
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static int N;
static char[][] operand;
static char[] ans;
static int[] c2i = new int[26];
static boolean[] used = new boolean[10];
public static void main(String[] args) {
while (true) {
N = ... | JAVA |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define F... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 |
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #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 ... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
const int d[9]={1,10,100,1000,10000,100000,1000000,10000000,100000000};
for(int N;cin>>N,N;){
string n[12];
for(int i=0;i<N;i++)
cin>>n[i];
map<char,int> m;
for(int i=0;i<N;i++)
for(int j=0;j<n[i].size();j++... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<iostream>
#include<vector>
#include<set>
#include<string>
#include<map>
#include<cmath>
#define P pair<int ,int>
#define N 10
using namespace std;
bool n_zero[N], f[N];
int coe[N], cnt, c;
void dfs(int n, int s) {
if (n == cnt) {
if (!s) c++;
return;
}
for (int i = 0; i < N; i++) {
if (f[i] || (!i... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | //#include<bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <cassert>
#include <cstdint>
#include <map>
using namespace std;
#define rep(i, j) for (int i = 0; i < (... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
typedef long long ll;
ll ans, n, cnt;
bool used[15];
ll keisu[15];
bool dame[15];
void dfs(int k, ll sum){
// cout << k << ' ' << sum << endl;
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first1 ,
BidirectionalIterator last1 ,
BidirectionalIterator first2 ,
BidirectionalIterator last2 )
{
if (( first1 == last1 ) || ( first2 == last2 )) {
return false ;
}
Bi... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<stdio.h>
#include<string.h>
int N,c2n[40],nf[15],p,len[15];
char S[15][15],ch[15];
int s2i(char *s)
{
int res=c2n[s[0]-'A'],i;
if(strlen(s)>1&&res==0)return -1;
for(i=1;s[i];i++)
{
res*=10;
res+=c2n[s[i]-'A'];
}
return res;
}
int check()
{
int p=len[N-1],i,j,c,t;
char *a=S[N-1];
if(len[N-1]!=0&... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
#define N 15
int imax, jmax, solution, digit[256], low[256];
char word[N][16];
bool ok[10];
void found(void){
for(int i=0; i<imax; i++){
if(strlen(word[i])>1&&digit[word[i][strlen(word[i])-1]]==0)return;
}
solution++;
}
void solv... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main{
Scanner sc=new Scanner(System.in);
int INF=1<<28;
double EPS=1e-9;
int n;
String[] ss;
void run(){
for(;;){
n=sc.nextInt();
if(n==0){
... | JAVA |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;
int weight[30] = {0}, zero[30] = {0};
void solve(string num, int &len, int &used, ma... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
int N,M;
string ss[101];
map<char,int> equ;
char cs[101];
int co[101];
bool isHead[1001];
int cnt;
int nums[101];
// Mツ古つづ個閉カツ篠堋づ可青板篠堋づーツ環づィツ督鳴づづゥ
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<bits/stdc++.h>
#define N 10
using namespace std;
int n,m,ans;
map<char,int> c;
set<char> ish;
bool used[N];
bool q[N];
string s;
int p[N];
void func(int x,int sum){
if(x==m){
if(!sum)ans++;
return;
}
for(int i=0;i<10;i++){
if(used[i])continue;
if(!i&&q[x])continue;
used[i]=true;
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | /* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n)... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include ... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(s) s.begin(),s.end()
int main(void){
int n;
while(cin>>n, n){
vector<string> s(n);
int a[256] = {};
bool not_zero[256] = {};
rep(i,n){
cin>>s[i];
int k = ... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
struct K {
int kei;
bool no_zero;
K(int kei,bool no_zero) :
kei(kei),no_zero(no_zero) {};
};
int mypow(int x,int n){
int ret = 1;
for(int i=0;i<n;i++){
ret *= x;
}
return ret;
}
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
using namespace std;
typedef ... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pai... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
usi... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
vector<char> a;
vector<int> v;
vector<int> f;
int ans(int k, int val, int used , int s){
int cnt = 0;
if(k == val){
if(s == 0) return 1;
else return 0;
}
else{
int tmp = v[k];
int f... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
bool used[10];
bool tabu[10];
int keisu[10];
int ans;
int cnt; // 文字数
void dfs(int k, int sum){
if (k == cnt) {
if (sum == 0) {
ans++;
}
return;
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool isHead[10];
int var[10], coe[10];
vector<char> ch;
typedef pair<int,int> P; // first=sum, second=state
vector<P> va,vb;
void solve( int dep, int st, int en, int sum, int state){
if( dep>en ){
if( st==0 ) va.push_back( P(sum,st... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
bool used[10];
bool tabu[10];
int keisu[10];
int ans;
int cnt; // 文字数
void dfs(int k, int sum){
if (k == cnt) {
if (sum == 0) {
ans++;
}
return;
... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define ALL(V) V.begin(),V.end()
template <typename T> using V = vector<T>;
const char base = 'A';
struct Solver {
ll N;
V<char> alp;
V<string> vs;
V<char> pre_alp;
Solver() {}
bool check(map<char, ll> &c2ll) {
for(cha... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | import java.util.*;
public class Main{
//1200 start
int size, n, ans, rightsize;
String [] data;
HashMap<Character, Integer> change, leftmap;
boolean [] used;
ArrayList<Character> data2;
HashSet<Character> nonzero;
private void doit(){
Scanner sc = new Scanner(System.in);
while(true){
n = sc.nextInt();... | JAVA |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long lli;
const lli MAXN = 12;
const lli ten[9] = {1,10,100,1000,10000,100000,1000000,10000000,100000000};
lli N, ans;
string S[MAXN];
lli num[128], mini[MAXN], maxi[MAXN];
void rec(lli i, lli j, lli sum, lli used) {
if(j == S[i].size()) ++i, j = 0;
if(i... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
int n;
int p10[8];
string s[12];
vector<char> chars;
int ad[26];
bool ngZero[26];
int dfs(int dep, int used, int s = 0) {
if (dep == chars.size()) {
return s == 0;
}
int i;... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <bits/stdc++.h>
int n, m;
bool done[10];
int map[256];
std::vector<char> check;
std::vector<std::string> list;
bool top[256];
int left;
int right;
int atom[256];
int btom[256];
int decode(const std::string & str) {
int time = 1;
int sum = 0;
for (int i = str.length() - 1; 0 <= i; --i) {
sum += map[... | CPP |
p00742 Verbal Arithmetic | Let's think about verbal arithmetic.
The material of this puzzle is a summation of non-negative integers represented in a decimal format, for example, as follows.
905 + 125 = 1030
In verbal arithmetic, every digit appearing in the equation is masked with an alphabetic character. A problem which has the above equa... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int it;
map<char, int> dic;
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
int N;
while (cin >> N, N) {
it = 0;
dic.clear();
vector<bool> flag(10);
vector<vector<int>> val(N);
for (int i = 0; i < N; i++) {
string s;
cin >> s;
for (auto c : s) ... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | import java.util.Arrays;
import java.util.Scanner;
public class Main {
Scanner sc = new Scanner(System.in);
int n;
int s;
int[] ans;
int memo[][];
int rep(int masked, int answer) {
if (memo[masked][answer] != -1) {
return memo[masked][answer];
}
int count = 0;
for (int i = 0; i < n; i++) {
if (... | JAVA |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | // 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... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | /*
x日間悩み、
動的計画法(メモ化)でやろうということを思いついた。
数学的に解が得られる方法は複数ありうる。
しかし、0 < m \leq 11 and 0 < n \leq 128 という制約の中で
制限に引っかからなそうなものとなると、状態の持ち方が限られる。
たとえば自然な発想として、
「n個のonjectの各部分集合を状態として持ち、それを類別するために必要な最小の
質問回数」を配列で持とうとするものが考えられる。
しかし2^{128}個のintはメモリの上においておくのは無理である。
よく考えてみると相当無駄がある。質問はm \leq 11個しかな... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... | PYTHON3 |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define s... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int M,N;
map<vector<int>,int>memo;
int f(int pre,const vector<int>&now)
{
if(now.size()<=1)return 0;
if(memo.find(now)!=memo.end())return memo[now];
int ret=114514;
for(int k=0;k<M;k++)
{
if(pre>>k&1)continue;
vector<int... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <cstdio>
#include <cstring>
#include <algorithm>
const int N = (1<<11) + 10;
int n, m, tot;
int obj[130];
int f[N][N];
int solve(int ask, int ans)
{
if(f[ask][ans] != -1) return f[ask][ans];
int cnt = 0;
for(int i = 1; i <= n; i++)
cnt += (ask & obj[i]) == ans;
if(cnt <= 1) return f[ask][ans] = 0;
in... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #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;
{
... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | import java.util.*;
public class Main {
private static int m, n;
private static int[][] memo = new int[1<<11][1<<11];
private static int[] f = new int[128];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
m = sc.nextInt();
... | JAVA |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static int M;
static int[] memo = new int[1 << 22];
public static void main(String[] args) {
while (true) {
M = sc.nextInt();
int N = sc.nextInt();
if (M == 0) ... | JAVA |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
#define INF (1 << 30)
int b(string str){
int res = 0;
for(int i = 0;i < str.size();i++){
res += (str[i] - '0') << i;
}
return res;
}
int num[108], n, m;
int dp[1 << 11][1 << 11];
int solve(int asked, int answer){
... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #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... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(i) i.begin(),i.end()
vs ss;
int b,n;
map<vi,int> memo;
int search(vi &in... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #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(n==2) return 1;
if(n==3) return 2;
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++)... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
int M,N;
string S[130];
int dp[(1<<11)][(1<<11)];
bool check(int st,int fr){
int mem[130]={};
int n = __builtin_popcount(st);
for(int i=0;i<M;i++){
if( st & (1<<i) ) {
for(int j=0;j<N;j++){
if( S[j][i] == '0' && !(fr & (1<<i)) ){
mem[j]++;
} else if(... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <map>
#include <assert.h>
using namespace std;
int n, m;
char object[200][20];
struct Set {
unsigned long long bit[2];
int count_bit() {
int sum = 0;
for (unsigned long long i = 0; i < 2; i++) {
for (unsigned l... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int s[130];
int dp[4000][4000];
bool v[4000][4000];
int how[4000];
int n,m;
int dfs(int x,int y)
{
if(v[x][y])return dp[x][y];
v[x][y]=1;
int ty=0,u=-1;
for(int i=0;i<m;i++)
if((s[i]&x)==y)
{
int z=s[i]^y;
how[z]++;
... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
struct I{
I(){
ios::sync_with_stdio(false);cin.tie(0);
}
}cww;
typedef long long LL;
typedef vector<LL> V;
#define cnt(l,r) (__builtin_popcountll(l)+__builtin_popcountll(r))
typedef tuple<LL,LL> P;
typedef map<P,int> Map;
int dfs(LL rest1,LL rest2,V &v1,V &v2,Map... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL MOD = 1000000007LL;
vector<int> v;
int cnt[1 << 11][1 << 11];
map<P, int> memo;
int m, n;
int solve(int q, int a) {
if (cnt[q][a] == 1) return 0;
if (memo.find(P(q, a)) != memo.end()) return memo[P(q, a)];
int ans ... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | //Twenty Questions
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define BMAX 177157
#define bmax (2<<11)+10
using namespace std;
#define INF 100
int dp[BMAX]={0};
int youso[BMAX]={0};
int obj[130][20];
int m,n;
int checkyouso(int);
int ch... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | // 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... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <fstream>
#include <map>
#include <cstring>
#include <vector>
using namespace std;
int n,m;
string bits[1001];
const int INF=1000000000;
//bitset<int> nums[1<<11];
map<set<int>,int> sets;
int id;
map<int,int> dp[1<<11];
//map<set<int... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
class state{
public:
int n;
unsigned long long data[2];
void set_data(int in){
if ( in >= 64)in-=64,data[1]|=(1LL << in);
else data[0]|=(1LL<<in);
}
bool oper... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | /*
x日間悩み、
動的計画法(メモ化)でやろうということを思いついた。
数学的に解が得られる方法は複数ありうる。
しかし、0 < m \leq 11 and 0 < n \leq 128 という制約の中で
制限に引っかからなそうなものとなると、状態の持ち方が限られる。
たとえば自然な発想として、
「n個のonjectの各部分集合を状態として持ち、それを類別するために必要な最小の
質問回数」を配列で持とうとするものが考えられる。
しかし2^{128}個のintはメモリの上においておくのは無理である。
よく考えてみると相当無駄がある。質問はm \leq 11個しかな... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 |
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
public class Main {
int INF = 1 << 28;
//long INF = 1L << 62;
double EPS = 1e-10;
short n, m;
BitSet[] yes, no;
void run() {
Scanner sc = new Scanner(System.in);
... | JAVA |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#includ... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dp[178000], N, M, power3[12]; char c[130][11];
vector<int>vec[178000];
void init() {
for (int i = 0; i < 178000; i++) { dp[i] = -1; vec[i].clear(); }
for (int i = 0; i < 130; i++) { for (int j = 0; j < 11; j++) c[i][j] = 0; }
}
int... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#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[make_pair(vi,used)];
if(vi.size() > (1<<(m-depth))) return 10... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
// n,m
int memo[130][13] = {0};
//現在の状態がvのときに、最悪残り手数がどうなっているか(int)のメモ
map<vector<int>, int> mp;
int solve(vector<int> now, int asked);
int main() {
int i, j;
while(1) {
vector<int> start;
cin >> m >> n;
if(m + n == 0) break;
for(i ... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | // 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... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <bitset>
using namespace std;
#define FOR(i,k,n) for(in... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#ifdef _WIN32
#define scanfll(x) scanf("%I64d", x)
#define printfll(x) printf("%I64d", x)
#else
#define scanfll(x) scanf("%lld", x)
#define printfll(x) printf("%lld", x)
#endif
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
char str[150][13];
int dp[180000];
int pow3[13];
int m,n;
int calc(int a){
if(~dp[a])return dp[a];
vector<int>c;
int key[13];
for(int i=0;i<m;i++)key[i]=a%pow3[i+1]/pow3[i];
for(int i=0;i<n;i++){
bool ok=true;
for(int j=0;j<m;j++){
... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int mem[1<<22];
int rec(int b,int *f,int *l){
if(l-f==1){
return 0;
}else if(mem[b]>=0){
return mem[b];
}else{
int m=99;
for(int i=0;i<11;i++){
if(!(b>>i*2&1)){
auto it=partition(f,l,[&](int x){
return x>>... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define INF (1<<24)
int M,N;
string field[150];
typedef vector<int> Group;
map<Group, int> memo;
int dfs(Group g, int used)
{
if(g.size() == 0) return -1;
if(g.size() == 1) return 0;
if(memo.count(g))... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <cstdio>
#include <cstring>
#include <string>
#include <set>
using namespace std;
int m, n;
string s[128];
int rec[177147];
bool check[128];
void trinary(int bit)
{
int pow = 1;
for (int i = 1; i < m; i++) pow *= 3;
for (; pow; pow /= 3) printf("%d", bit / pow % 3);
printf("\n");
}
int calc(int bit)
{
... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | import java.util.Arrays;
import java.util.BitSet;
import java.util.Scanner;
//Twenty Questions
public class Main{
int n, m;
int[] s;
BitSet[] yes, no;
int[][] mem;
int f(int S, int SY){
if(mem[S][SY]!=-1)return mem[S][SY];
int res = m;
BitSet bs = new BitSet(n);
bs.set(0, n, true);
for(int j=0;j<m;j+... | JAVA |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | 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 = [[0] * (1 << m) for i in range(1 << m)]
bits = [1 << i for i in range(m)]
for mask in reversed(range(1 << m)):
s = Counter(obj ... | PYTHON3 |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
int m, n;
int po[13] = {};
void init(){
po[0] = 1;
for(int i = 1; i < 13; i++) po[i] = po[i - 1] * 3;
}
int dfs(vector<string> &data, vector<int> &dp, int S){
int ret = dp[S];
if(ret != MOD) return re... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #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;
... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
int cnt[2100][2100];
int dp[2100][2100];
int val[130];
char s[15];
int dfs(int s1,int s2) {
if (cnt[s1][s2]<=1) return 0;
if (dp[s1][s2]!=-1) return dp[s1][s2];
for (int i=0;i<m;i++) {
if (s1&... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
int M, N;
vector<string>sts;
int memo[1 << 12][128];
int getans(const vector<int>vs, bitset<11>used) {
if (memo[us... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #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... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #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... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> vi;
typedef vector<vi> vvi;
typed... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <iostream>
#include <string>
#define inf 1000000000
#define N 177147
using namespace std;
int m, n;
int obj[130];
int memo[N];
int encode(int state[], int pos, int val)
{
int ret = 0;
for(int i = m-1; i >= 0; i--){
ret *= 3;
if(i == pos) ret += val;
else ret += state[i];
}
return ret;
}
int dfs(i... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #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... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include<cstdio>
#include<string>
#include<map>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
const int MAXN=1<<11;
int dp[MAXN+5][MAXN+5];
int num[200];
int n,m;
///dp[s1][s2]=min(dp[s1|1<<k][s2],dp[s1|1<<k][s2^(1<<k)])+1;
int dfs(int x,int y)
{
if(dp[x][y]!=1e9)return dp[x][y];
in... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif
typedef long long int ll;
typedef pair<int,int> ... | CPP |
p00881 Twenty Questions | 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 of boole... | 7 | 0 | #include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.