Problem:
問題 D
列の構成
問題文
1
から
N
までの相異なる整数が
N / 2
個書かれたカードがいくつか与えられるので，次の条件を満たすような長さ
N
の数列
seq
を
1
つ作って出力して欲しい．
seq
の各要素は
0
か
1
である．
すべてのカードについて以下が成り立つ： カードに書かれた数字を
card[1], ..., card[N/2]
とする．このときカードに書かれた部分の和:
seq[card[1]] + ... + seq[card[N/2]]
が
N / 8
以上かつ
3N / 8
以下になっている．
例えば，
N = 8
でカードが
2
枚渡され，カードに書かれている数字がそれぞれ
[1, 2, 7, 8]
，
[4, 5, 7, 8]
であったとする．このとき
seq=[0, 1, 0, 1, 0, 1, 0, 1]
や
seq=[0, 0, 0, 0, 1, 1, 1, 1]
とおくと条件を満たすようにできている．
入力形式
入力は次の形式で与えられる．
N
K
card
1
[1]
card
1
[2]
...
card
1
[N/2]
card
2
[1]
card
2
[2]
...
card
2
[N/2]
...
card
K
[1]
card
K
[2]
...
card
K
[N/2]
1
行目において
N
は構成するべき数列の長さ，
K
はカードの枚数である．
続く
K
行には各カードの情報が与えられる．
card
i
[1], ..., card
i
[N/2]
が
i
番目のカードに書かれている数字である．
出力形式
seq
の
i
番目の要素が
i
文字目に対応するように数列
seq
を
1
行に出力せよ．
なお，どの入力に対しても解は必ず少なくとも
1
つは存在する．
制約
8 ≤ N ≤ 1,000
,
1≤ K ≤ N / 2
N
は
8
の倍数
1 ≤ card
i
[1] < card
i
[2] < ... < card
i
[N/2] ≤ N
入出力例
入力例 1
8 2
1 2 7 8
4 5 7 8
出力例 1
01010101
入力例 2
8 3
2 3 4 6
3 4 5 8
3 4 6 8
出力例 2
01110011

Submitted solutions:

code_snippet: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_K = MAX_N / 2;

/* typedef */

/* global variables */

int cards[MAX_K][MAX_N / 2];
int seq[MAX_N];

/* subroutines */

void gen_seq(int n) {
  for (int i = 0; i < n; i++) seq[i] = rand() & 1;
}

/* main */

int main() {
  srand(time(NULL));

  int n, k;
  cin >> n >> k;

  int nh = n / 2;
  int cmin = n / 8, cmax = 3 * cmin;

  memset(cards, 0, sizeof(cards));
  
  for (int i = 0; i < k; i++)
    for (int j = 0; j < nh; j++) {
      cin >> cards[i][j];
      cards[i][j]--;
    }

  for (;;) {
    gen_seq(n);

    bool ok = true;
    for (int i = 0; i < k; i++) {
      int cnt = 0;
      for (int j = 0; j < nh; j++) cnt += seq[cards[i][j]];
      if (cnt < cmin || cnt > cmax) {
	ok = false;
	break;
      }
    }

    if (ok) break;
  }

  for (int i = 0; i < n; i++) cout << seq[i]; cout << endl;
  
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4424
final_rank: 7

code_snippet: #include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>

bool is_match(const std::vector<int>& set, const std::vector<std::vector<int>> &cards) {
	for (const auto& card : cards) {
		int count{ 0 };
		for (const auto& c : card) count += set[c];
		if (count * 8 < set.size() || set.size() * 3 < count * 8) return false;
	}
	return true;
}
void set_random(std::vector<int>& set, std::mt19937& rand) {
	for (auto& b : set) b = rand() & 1;
}
int main() {
	int n, k; std::cin >> n >> k;
	std::vector<std::vector<int>> cards(k, std::vector<int>(n / 2));
	for (auto& card : cards) for (auto& c : card) {
		std::cin >> c; --c;
	}
	std::vector<int> set(n);
	std::mt19937 rand;
	set_random(set, rand);
	while (!is_match(set, cards)) set_random(set, rand);
	for (const auto& s : set) std::cout << s;
	std::cout << std::endl;
}
accuracy: 1
time_ms: 30
memory_kb: 3932
final_rank: 8

code_snippet: #include <iostream>
#include <vector>
#include <random>
using namespace std;
typedef long long int ll;

int card[1100][1100];
int seq[1100];

int main(){
	int n,k; cin >> n >> k;
	for(int i=0;i<k;i++){
		for(int j=0;j<n/2;j++){
			cin >> card[i][j];
			card[i][j]--;
		}
	}
	random_device rnd;
	mt19937 mt(rnd());
	while(1){
		for(int i=0;i<n;i++){
			seq[i]=mt()%2;
		}
		bool ok=true;
		for(int i=0;i<k;i++){
			int sum=0;
			for(int j=0;j<n/2;j++){
				sum+=seq[card[i][j]];
				if(sum>3*n/8)ok=false;
			}
			if(sum<n/8)ok=false;
			if(!ok)break;
		}
		if(ok){
			for(int i=0;i<n;i++){
				cout << seq[i];
			}
			cout << endl;
			return 0;
		}
	}
}
accuracy: 1
time_ms: 30
memory_kb: 5252
final_rank: 13

code_snippet: #include<iostream>
#include<ctime>
#include<cstdlib>

using namespace std;

int main()
{
    
    int n,k;
    int card[505][505];
    
    cin >> n >> k;
    for(int i=0;i<k;i++){
        for(int j=0;j<n/2;j++) cin >> card[i][j];
    }
    
    srand( (unsigned int)time(NULL) );
    
    int sum,cnt,ans[1010];
    
    do{
        
        for(int i=1;i<=n;i++) ans[i] = rand() % 2;
        
        cnt = 0;
        for(int i=0;i<k;i++){
            sum = 0;
            for(int j=0;j<n/2;j++){
                sum += ans[ card[i][j] ];
            }
            if(sum >= n/8 && sum <= 3*n/8) cnt++;
        }
        
   }while(cnt < k);
    
    for(int i=1;i<=n;i++) cout << ans[i];
    cout << endl;
    
    return(0);
}
accuracy: 1
time_ms: 30
memory_kb: 4100
final_rank: 9

code_snippet: #include <bits/stdc++.h>

using namespace std;

int main()
{
    
    int n,k;
    int card[505][505];
    
    cin >> n >> k;
    for(int i=0;i<k;i++){
        for(int j=0;j<n/2;j++) cin >> card[i][j];
    }
    
    srand( (unsigned int)time(NULL) );
    
    int sum,cnt,ans[1010];
    
    do{
        
        for(int i=1;i<=n;i++) ans[i] = rand() % 2;
        
        cnt = 0;
        for(int i=0;i<k;i++){
            sum = 0;
            for(int j=0;j<n/2;j++){
                sum += ans[ card[i][j] ];
            }
            if(sum >= n/8 && sum <= 3*n/8) cnt++;
        }
        
   }while(cnt < k);
    
    for(int i=1;i<=n;i++) cout << ans[i];
    cout << endl;
    
    return(0);
}
accuracy: 1
time_ms: 30
memory_kb: 4108
final_rank: 10

code_snippet: #include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int N, K;
int ub, lb;
int ans[1008];
vector<vector<int>> v(1001);

bool check()
{

    for (int i = 0; i < K; ++i)
    {
        int cnt = 0;
        for (int j = 0; j < N / 2; ++j)
        {
            cnt += ans[v[i][j]];
        }
        if (cnt < lb || cnt > ub)
            return false;
    }
    return true;
}

void solve()
{
    for (int i = 0; i < N / 2; ++i)
        ans[i] = 1;
    while (1)
    {
        std::random_device seed_gen;
        std::mt19937 engine(seed_gen());
        shuffle(ans, ans + N, engine);
        if (check())
            break;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    cin >> N >> K;
    lb = N / 8;
    ub = 3 * lb;

    for (int i = 0; i < K; ++i)
    {
        for (int j = 0; j < N / 2; ++j)
        {
            int a;
            cin >> a;
            a--;
            v[i].push_back(a);
        }
    }
    solve();

    for (int i = 0; i < N; ++i)
    {
        cout << ans[i];
    }
    cout << endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3784
final_rank: 2

code_snippet: #define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int card[550][550];

int main(){
	
	int N, K;
	cin >> N >> K;
	
	for(int i = 0; i < K; i++){
		for(int j = 0; j < N / 2; j++){
			cin >> card[i][j];
			card[i][j]--;
		}
	}
	
	int ans[1100];
	
	while(true){
		for(int i = 0; i < N; i++){
			ans[i] = rand() % 2;
		}
		bool flag = true;
		for(int i = 0; i < K; i++){
			int cnt = 0;
			for(int j = 0; j < N / 2; j++){
				cnt += ans[card[i][j]];
			}
			if(cnt < N / 8 || cnt > 3 * N / 8){
				flag = false;
				break;
			}
		}
		if(flag){
			break;
		}
	}
	
	for(int i = 0; i < N; i++){
		cout << ans[i];
	}
	cout << endl;
	
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 4128
final_rank: 11

code_snippet: #include <iostream>
#include <vector>
#include <random>
using namespace std;

int main(){
	mt19937 mt(12345);
	int n,k;
	cin >> n >> k;
	vector<vector<int> > card(k, vector<int>(n/2));
	for(int i=0; i<k; i++){
		for(int j=0; j<n/2; j++){
			cin >> card[i][j];
			card[i][j]--;
		}
	}
	string ans = "";
	while(1){
		bool success = true;
		vector<int> seq(n);
		for(int i=0; i<n; i++){
			seq[i] = mt()%2;
		}
		for(int i=0; i<k; i++){
			int sum = 0;
			for(int j=0; j<n/2; j++){
				sum += seq[card[i][j]];
			}
			if(sum < n/8 || n*3/8 < sum){
				success = false;
				break;
			}
		}
		if(success){
			for(int i=0; i<n; i++){
				ans += seq[i] +'0';
			}
			break;
		}
	}
	cout << ans << endl;
	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3828
final_rank: 15

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#include<random>
#pragma warning(disable:4996)
using namespace std;

bool check(const vector<int>&anss, const vector<vector<int>>&cards) {
	for (auto card : cards) {
		int sum=0;
		for (auto num : card) {
			sum+=anss[num];
		}
		if(sum<anss.size()/8||sum>anss.size()*3/8)return false;
	}
	return true;
}

int main() {
	int N,M;cin>>N>>M;
	vector<vector<int>>cards(M);
	for (int i = 0; i < M; ++i) {
		cards[i].resize(N/2);
		for(int j = 0; j < N / 2; ++j) {
			cin>>cards[i][j];
			cards[i][j]--;
		}
	}
	vector<int>anss(N,0);
	for (int i = 0; i < N / 2; ++i) {
		anss[i]=1;
	}
	random_device rnd;
	mt19937 mt(rnd());
	shuffle(anss.begin(),anss.end(),mt);
	while (true) {
		if (check(anss, cards)) {
			break;
		}
		else {
			for (auto card : cards) {
				int sum = 0;
				for (auto num : card) {
					sum += anss[num];
				}
				if (sum < anss.size() / 8) {
					int use;
					int unuse;
					while (true) {
						int n = mt() % (card.size() * 2);
						if (!binary_search(card.begin(), card.end(), n)&&anss[n]) {
							unuse = n;
							break;
						}
					}
					while (true) {
						int n = card[mt()%card.size()];
						if ( !anss[n]) {
							use = n;
							break;
						}
					}
					swap(anss[use],anss[unuse]);
				}
				else if (sum > 3*anss.size() / 8) {
					int use;
					int unuse;
					while (true) {
						int n = mt() % (card.size() * 2);
						if (!binary_search(card.begin(), card.end(), n) && !anss[n]) {
							use = n;
							break;
						}
					}
					while (true) {
						int n = card[mt() % card.size()];
						if (anss[n]) {
							unuse = n;
							break;
						}
					}
					swap(anss[use], anss[unuse]);
				}
			}
		}
	}
	for (int i = 0; i < anss.size(); ++i) {
		cout<<anss[i];
	}
	cout<<endl;
	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3896
final_rank: 16

code_snippet: #include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
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;




int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	int table[K][N/2];

	for(int row = 0; row < K; row++){
		for(int col = 0; col < N/2; col++){
			scanf("%d",&table[row][col]);
			table[row][col]--;
		}
	}

	int ans[N];
	for(int i = 0; i < N/2; i++)ans[i] = 1;
	for(int i = N/2; i < N; i++)ans[i] = 0;

	bool FLG;
	int sum;

	while(true){
		FLG = true;
		for(int i = 0; i < K; i++){
			sum = 0;
			for(int a = 0; a < N/2; a++){
				sum += ans[table[i][a]];
			}
			if(sum < N/8 || sum > 3*N/8){
				FLG = false;
				break;
			}
		}

		if(FLG)break;

		random_shuffle(ans,ans+N);

	}

	for(int i = 0; i < N; i++)printf("%d",ans[i]);
	printf("\n");

	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4212
final_rank: 4

code_snippet: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,k,a[9999][9999],b[9999];
int main(){
  cin>>n>>k;
  r(i,k)r(j,n/2)scanf("%d",&a[i][j]);
  while(1){
    r(i,n)b[i+1]=rand()%2;
    r(i,k){
      int cnt=0;
      r(j,n/2)cnt+=b[a[i][j]];
      if(cnt < n/8 || 3*n/8 < cnt)goto L;
    }
    r(i,n)cout<<b[i+1];
    cout<<endl;
    return 0;
    L:;
  }
}
accuracy: 1
time_ms: 20
memory_kb: 6152
final_rank: 12

code_snippet: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,k,a[9999][9999],b[9999];
int main(){
  cin>>n>>k;
  r(i,k)r(j,n/2)cin>>a[i][j];
  while(1){
    r(i,n)b[i+1]=rand()%2;
    r(i,k){
      int cnt=0;
      r(j,n/2)cnt+=b[a[i][j]];
      if(cnt < n/8 || 3*n/8 < cnt)goto L;
    }
    r(i,n)cout<<b[i+1];
    cout<<endl;
    return 0;
    L:;
  }
}
accuracy: 1
time_ms: 30
memory_kb: 6088
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,k;
  cin>>n>>k;
  vector< vector<Int> > v(k);
  for(Int i=0;i<k;i++){
    v[i].resize(n/2);
    for(Int j=0;j<n/2;j++) cin>>v[i][j],v[i][j]--;
  }

  auto check=[&](string s){
    for(Int i=0;i<k;i++){
      Int tmp=0;
      for(Int j=0;j<n/2;j++)
	tmp+=(s[v[i][j]]=='1');
      //cout<<i<<":"<<tmp<<endl;
      if(tmp<n/8||tmp>3*n/8) return 0;
    }
    return 1;
  };
  
  srand((unsigned)time(NULL));
  while(1){
    string s;
    for(Int i=0;i<n;i++)
      s.push_back(char('0'+(rand()%2)));
    if(check(s)){
      cout<<s<<endl;
      return 0;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 4564
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;

int N,K;
set<int> G[500];

int main(){
  cin>>N>>K;
  for(int i=0;i<K;i++){
    for(int j=0;j<N/2;j++){
      int k;
      cin>>k;
      k--;
      G[i].insert(k);
    }
  }
  vector<int> t(N);
  for(int i=0;i<N;i++)t[i]=i;
  int cc=0;
  while(cc<1000000){
    cc+=N;
    random_shuffle(t.begin(),t.end());
    vector<int> sum(K,0);
    for(int i=0;i<N/2;i++){
      int id=t[i];
      for(int j=0;j<K;j++){
        sum[j]+=G[j].count(id);
      }
    }
    int mini=1e9,maxm=0;
    for(int i=0;i<K;i++){
      mini=min(mini,sum[i]);
      maxm=max(maxm,sum[i]);
    }
    if(N/8<=mini&&maxm<=N/8*3){
      vector<int> ans(N,0);
      for(int i=0;i<N/2;i++)ans[ t[i] ]=1;
      for(int i=0;i<N;i++)cout<<ans[i];
      cout<<endl;
      break;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 14840
final_rank: 20

code_snippet: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int a[500][500];
int v[1000];
int main() {
	int n, k; scanf("%d%d", &n, &k);
	rep(i, k)rep(j, n / 2)scanf("%d", &a[i][j]), a[i][j]--;
	random_device rnd; mt19937 mt(rnd());
	while (1) {
		rep(i, n)v[i] = mt() % 2;
		rep(i, k) {
			int sum = 0;
			rep(j, n / 2) {
				sum += v[a[i][j]];
				if (sum > 3 * n / 8)goto g;
				if (sum + n / 2 - j - 1 < n / 8)goto g;
			}
		}
		rep(i, n)printf("%d", v[i]); puts("");
		return 0;
	g:;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 4268
final_rank: 5

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;
  int c[1010][505];
  rep(i, K) rep(j, N/2) cin >> c[i][j];
  srand((unsigned)time(NULL));
  while(1) {
    string bin = "";
    rep(i, N) bin += '0' + rand()%2;
    bool flag = true;
    rep(i, K) {
      int sum = 0;
      rep(j, N/2) sum += bin[c[i][j]-1] - '0';
      if(sum < N/8 || 3*N/8 < sum) flag = false;
      if(!flag) break;
    }
    if(flag) {
      cout << bin << endl;
      break;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 5132
final_rank: 6

code_snippet: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<vector<int>> card(K, vector<int>(N/2));
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < N/2; j++) {
            cin >> card[i][j];
            card[i][j]--;
        }
    }
    
    random_device rd;
    mt19937 mt(rd());
    bool finished = 0;
    while (!finished) {
        finished = 1;
        
        vector<int> seq(N);
        for (int i = 0; i < N; i++) {
            seq[i] = mt() % 2;
        }
        
        for (int i = 0; i < K; i++) {
            int sum = 0;
            for (int j = 0; j < N/2; j++) {
                sum += seq[card[i][j]];
            }
            if (sum < N/8 || sum > 3*N/8) {
                finished = 0;
                break;
            }
        }

        if (finished) {
            for (int i = 0; i < N; i++) {
                cout << seq[i];
            }
            cout << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3816
final_rank: 14

code_snippet: #include<iostream>
#include<algorithm>
#include<time.h>
using namespace std;
int a[10000][1000], c[10000], n, k;
int main() {
	srand((unsigned)time(NULL));
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < n / 2; j++) {
			cin >> a[i][j];
		}
	}
	while (true) {
		for (int i = 0; i < n; i++) c[i] = (unsigned)(rand()) % 2;
		for (int i = 0; i < k; i++) {
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				cnt += c[a[i][j] - 1];
			}
			if (cnt < n / 8 || cnt>3 * n / 8) { goto E; }
		}
		for (int i = 0; i < n; i++) { cout << c[i]; }
		cout << endl; goto F;
	E:;
	}
F:;
	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3124
final_rank: 19

code_snippet: #include <stdio.h>
#include <stdlib.h>
int N, K, card[500][500], r[1000];
int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N / 2; j++) {
			scanf("%d", &card[i][j]);
		}
	}
	while (true) {
		for (int i = 0; i < N; i++) r[i] = rand() % 2;
		bool flag = true;
		for (int i = 0; i < K; i++) {
			int c = 0;
			for (int j = 0; j < N / 2; j++) {
				if (r[card[i][j] - 1]) c++;
			}
			if (c < N / 8 || 3 * N / 8 < c) { flag = false; break; }
		}
		if (flag) {
			for (int i = 0; i < N; i++) {
				printf("%d", r[i]);
			}
			printf("\n"); break;
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3696
final_rank: 1

code_snippet: #include <ctime>
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
int N, K, card[500][500], r[1000];
int main() {
	srand((unsigned)time(NULL));
	scanf("%d%d", &N, &K);
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N / 2; j++) {
			scanf("%d", &card[i][j]);
		}
	}
	while (true) {
		for (int i = 0; i < N; i++) r[i] = rand() % 2;
		bool flag = true;
		for (int i = 0; i < K; i++) {
			int c = 0;
			for (int j = 0; j < N / 2; j++) {
				if (r[card[i][j] - 1]) c++;
			}
			if (c < N / 8 || 3 * N / 8 < c) { flag = false; break; }
		}
		if (flag) {
			for (int i = 0; i < N; i++) {
				printf("%d", r[i]);
			}
			printf("\n"); break;
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4204
final_rank: 3