Submission #816559


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;

  vector<bool> Flag(10, true);
  vector<string> D(K);
  int tmp;
  for(int i = 0; i < K; i++) {
    cin >> tmp;
    D[i] = to_string(tmp);
    Flag[tmp] = false;
  }

  vector<string> available;
  for(int i = 0; i < 10; i++) {
    if(Flag[i]) available.push_back(to_string(i));
  }

  bool flag;
  if(available.size() < D.size()) {
    for(int i = N; i < 10000; i++) {
      string s = to_string(i);
      flag = false;
      for(int j = 0; j < s.size(); j++) {
	for(int k = 0; k < available.size(); k++) {
	  if(s[j] == available[k][0]) {flag = true; break;}
	}
	if(!flag) break;
      }
      if(flag) {cout << i << endl; return 0;}
    }
  } else {
    for(int i = N; i < 10000; i++) {
      string s = to_string(i);
      flag = false;
      for(int j = 0; j < s.size(); j++) {
	for(int k = 0; k < D.size(); k++) {
	  const char *ss = s.c_str();
	  if(s[j] != D[k][0]) {flag = true; break;}
	}
	if(!flag) break;
      }
      if(flag) {cout << i << endl; return 0;}
    }
  }
  cout << "error" << endl;

  return 0;
}

Submission Info

Submission Time
Task C - Iroha's Obsession
User gamera416
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1261 Byte
Status WA
Exec Time 6 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status AC
AC × 5
WA × 5
Set Name Test Cases
Sample
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_X_01.txt, subtask1_X_02.txt, subtask1_X_03.txt, subtask1_X_04.txt, subtask1_X_05.txt, subtask1_X_06.txt, subtask1_X_07.txt, subtask1_X_08.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 4 ms 256 KB
subtask0_sample_02.txt AC 4 ms 256 KB
subtask1_X_01.txt AC 6 ms 256 KB
subtask1_X_02.txt WA 4 ms 256 KB
subtask1_X_03.txt WA 4 ms 256 KB
subtask1_X_04.txt WA 4 ms 256 KB
subtask1_X_05.txt AC 4 ms 256 KB
subtask1_X_06.txt WA 4 ms 256 KB
subtask1_X_07.txt WA 4 ms 256 KB
subtask1_X_08.txt AC 4 ms 256 KB