Submission #65813791


Source Code Expand

// 綺麗に解きなおし

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

/////////////////// メイン ///////////////////

int main () {
  
  //////////////////// 入力 ////////////////////

  string t, u;
  cin >> t >> u;

  //////////////// 出力変数定義 ////////////////

  // 出力変数文字列をとりあえずNoで用意しておく
  // これにより、1つでも条件に合う部分を見つけたらYesに変えるだけで済み、
  // 1つも見つからなかった場合の対応をする必要がなくなる
  string result = "No";

  //////////////////// 処理 ////////////////////

  // tの中の?の位置4ヶ所を検索
  vector<int> questions;
  for (int i=0; i<t.size(); i++) {
    if (t.at(i)=='?') questions.emplace_back(i);
  }

  // 4ヶ所それぞれに全アルファベットを入れる全探索4重ループ
  for (char c1='a'; c1<='z'; c1++) {
    t.at(questions.at(0)) = c1;
    for (char c2='a'; c2<='z'; c2++) {
      t.at(questions.at(1)) = c2;
      for (char c3='a'; c3<='z'; c3++) {
      t.at(questions.at(2)) = c3;
        for (char c4='a'; c4<='z'; c4++) {
        t.at(questions.at(3)) = c4;

          // そうして作ったtにuが含まれるかを調べて、含まれるならYesにする
          if (t.contains(u)) result = "Yes";

        }
      }
    }
  }

  //////////////////// 出力 ////////////////////

  cout << result << endl;

  //////////////////// 終了 ////////////////////

  return 0;

}

Submission Info

Submission Time
Task B - Four Hidden
User wightou
Language C++ 23 (gcc 12.2)
Score 250
Code Size 1535 Byte
Status AC
Exec Time 13 ms
Memory 3616 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:26:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   26 |   for (int i=0; i<t.size(); i++) {
      |                 ~^~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 6 ms 3520 KiB
00_sample_02.txt AC 6 ms 3424 KiB
00_sample_03.txt AC 6 ms 3452 KiB
01_random_01.txt AC 13 ms 3424 KiB
01_random_02.txt AC 6 ms 3388 KiB
01_random_03.txt AC 6 ms 3464 KiB
01_random_04.txt AC 10 ms 3420 KiB
01_random_05.txt AC 12 ms 3520 KiB
01_random_06.txt AC 7 ms 3516 KiB
01_random_07.txt AC 8 ms 3424 KiB
01_random_08.txt AC 6 ms 3428 KiB
01_random_09.txt AC 8 ms 3460 KiB
01_random_10.txt AC 7 ms 3424 KiB
01_random_11.txt AC 9 ms 3616 KiB
01_random_12.txt AC 6 ms 3424 KiB
01_random_13.txt AC 6 ms 3396 KiB
01_random_14.txt AC 9 ms 3428 KiB
01_random_15.txt AC 6 ms 3456 KiB
01_random_16.txt AC 9 ms 3356 KiB
01_random_17.txt AC 10 ms 3428 KiB
01_random_18.txt AC 6 ms 3424 KiB
01_random_19.txt AC 6 ms 3440 KiB
01_random_20.txt AC 6 ms 3584 KiB
02_handmade_01.txt AC 9 ms 3520 KiB
02_handmade_02.txt AC 6 ms 3464 KiB