結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー as277575as277575
提出日時 2023-08-04 21:48:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 2,235 bytes
コンパイル時間 1,216 ms
コンパイル使用メモリ 125,604 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-08-23 01:43:06
合計ジャッジ時間 2,953 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 30 ms
6,888 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 45 ms
8,704 KB
testcase_06 AC 14 ms
4,700 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 13 ms
4,572 KB
testcase_10 AC 29 ms
6,184 KB
testcase_11 AC 15 ms
5,004 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 13 ms
4,376 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 13 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 7 ms
4,380 KB
testcase_25 AC 10 ms
4,376 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 10 ms
4,380 KB
testcase_28 AC 8 ms
4,376 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 13 ms
4,376 KB
testcase_32 AC 5 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:100:49: 警告: narrowing conversion of ‘(((long long int)i) + k)’ from ‘long long int’ to ‘int’ [-Wnarrowing]
  100 |     for (int j : initializer_list<int>{i + 1, i + k})
      |                                               ~~^~~
main.cpp:100:49: 警告: narrowing conversion of ‘(((long long int)i) + k)’ from ‘long long int’ to ‘int’ [-Wnarrowing]

ソースコード

diff #

#include <algorithm>
#include <bit>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>
#include <string>

using namespace::std;

template<typename T, typename U>
ostream& operator<< (ostream& o, const pair<T, U>& p) {
  o << "<" << p.first << ", " << p.second << ">";
  return o;
}

template <typename T>
ostream& operator<< (ostream& o, const vector<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename T>
ostream& operator<< (ostream& o, const set<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename T>
ostream& operator<< (ostream& o, const deque<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

template <typename K, typename V>
ostream& operator<<(ostream& o, const unordered_map<K, V>& m) {
  o << "{";
  for (const auto& [k, v] : m)
    o << " " << k << ": " << v << ",";
  o << "}";
  return o;
}

template <typename T>
ostream& operator<< (ostream& o, const vector<vector<T>>& v) {
 for (const auto& x : v) o << x << endl;
 return o;
}

ostream& operator<< (ostream& o, const vector<string>& v) {
 for (const auto& x : v) o << x << endl;
 return o;
}



template <typename T>
istream& operator>> (istream& i, vector<T>& v) {
  for (auto& x : v) i >> x;
  return i;
}

istream& operator>> (istream& i, pair<int, int>& p) {
  i >> p.first >> p.second;
  return i;
}



int main() {
  ios::sync_with_stdio(false);
  long long n, k, m1;
  cin >> n >> k >> m1;
  unordered_set<int> d;
  for (int i = 0; i < m1; ++i) {
    int a;
    cin >> a;
    d.insert(a);
  }
  unordered_set<int> c;
  int m2;
  cin >> m2;
  for (int i = 0; i < m2; ++i) {
    int b;
    cin >> b;
    c.insert(b);
  }
  vector<pair<bool, bool>> v(n + 1);
  v[0].first = true;
  for (int i = 0; i < n; ++i) {
    for (int j : initializer_list<int>{i + 1, i + k})
      if (j <= n) {
        v[j].first |= !d.count(j) && (v[i].first || (v[i].second && c.count(j)));
        v[j].second |= v[i].first || v[i].second;
      }
  }
  
  cout << (v[n].first ? "Yes" : "No") << endl;

  return 0;
}


0