結果
| 問題 | No.3750 Mischievous Resident (Easy) |
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2026-10-02 21:30:14 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 6,163 bytes |
| 記録 | |
| コンパイル時間 | 2,441 ms |
| コンパイル使用メモリ | 345,032 KB |
| 実行使用メモリ | 9,928 KB |
| 最終ジャッジ日時 | 2026-10-02 21:30:46 |
| 合計ジャッジ時間 | 6,535 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 WA * 15 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
// using mint = modint1000000007;
// const int mod = 1000000007;
// using mint = modint998244353;
// const int mod = 998244353;
// const int INF = 1e9;
// const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, l, r) for (int i = (l); i < (r); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, l, r) for (int i = (r)-1; i >= (l); --i)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define P pair<int, int>
template<typename A, typename B> inline bool chmax(A& a, const B& b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A& a, const B& b) { if (a > b) { a = b; return true; } return false; }
#ifndef KWM_T_STL_SORTED_SET_SAFE_HPP
#define KWM_T_STL_SORTED_SET_SAFE_HPP
#include <set>
#include <iterator>
#include <cstddef>
namespace kwm_t::stl::sorted_set_safe {
// ===== 近傍探索 =====
// <= x(multiset の場合、x が複数あると「最後の x」)
template <class Set, class T>
inline typename Set::const_iterator it_prev_leq(const Set& s, const T& x) {
auto it = s.upper_bound(x);
if (it == s.begin()) return s.end();
--it;
return it;
}
// < x(multiset の場合、x 未満の最後)
template <class Set, class T>
inline typename Set::const_iterator it_prev_less(const Set& s, const T& x) {
auto it = s.lower_bound(x);
if (it == s.begin()) return s.end();
--it;
return it;
}
// >= x(multiset の場合、x が複数あれば最初の x)
template <class Set, class T>
inline typename Set::const_iterator it_next_geq(const Set& s, const T& x) {
auto it = s.lower_bound(x);
if (it == s.end()) return s.end();
return it;
}
// > x
template <class Set, class T>
inline typename Set::const_iterator it_next_greater(const Set& s, const T& x) {
auto it = s.upper_bound(x);
if (it == s.end()) return s.end();
return it;
}
// ===== 基本ユーティリティ =====
template <class Set, class T>
inline bool contains(const Set& s, const T& x) {
auto it = s.lower_bound(x);
return it != s.end() && *it == x;
}
// set: 唯一の x / multiset: x のどれか 1 個
template <class Set, class T>
inline typename Set::const_iterator it_find(const Set& s, const T& x) {
return s.find(x);
}
template <class Set>
inline typename Set::const_iterator it_min(const Set& s) {
if (s.empty()) return s.end();
return s.begin();
}
template <class Set>
inline typename Set::const_iterator it_max(const Set& s) {
if (s.empty()) return s.end();
return std::prev(s.end());
}
// ===== 区間 =====
template <class Set, class T>
inline bool exists_in_range(const Set& s, const T& l, const T& r) {
auto it = s.lower_bound(l);
return it != s.end() && *it < r;
}
// set / multiset ともに O(k)(k = 区間内の要素数)
template <class Set, class T>
inline std::size_t count_range(const Set& s, const T& l, const T& r) {
auto L = s.lower_bound(l);
auto R = s.lower_bound(r);
return std::distance(L, R);
}
// ===== erase / pop =====
// set: 唯一の x / multiset: x のどれか 1 個だけ消す
template <class Set, class T>
inline bool erase_one(Set& s, const T& x) {
auto it = s.find(x);
if (it == s.end()) return false;
s.erase(it);
return true;
}
template <class Set>
inline bool pop_min(Set& s, typename Set::value_type& out) {
if (s.empty()) return false;
auto it = s.begin();
out = *it;
s.erase(it);
return true;
}
template <class Set>
inline bool pop_max(Set& s, typename Set::value_type& out) {
if (s.empty()) return false;
auto it = std::prev(s.end());
out = *it;
s.erase(it);
return true;
}
// ===== multiset 前提ユーティリティ =====
// multiset 前提:
// x が複数ある場合の「最初の x」
template <class Set, class T>
inline typename Set::const_iterator it_find_first(const Set& s, const T& x) {
auto it = s.lower_bound(x);
if (it == s.end() || *it != x) return s.end();
return it;
}
// multiset 前提:
// x が複数ある場合の「最後の x」
template <class Set, class T>
inline typename Set::const_iterator it_find_last(const Set& s, const T& x) {
auto it = s.upper_bound(x);
if (it == s.begin()) return s.end();
--it;
if (*it != x) return s.end();
return it;
}
// multiset 前提:
// x を全部消す(set でも 0 or 1 個消える)
template <class Set, class T>
inline std::size_t erase_all(Set& s, const T& x) {
auto L = s.lower_bound(x);
auto R = s.upper_bound(x);
std::size_t cnt = std::distance(L, R);
s.erase(L, R);
return cnt;
}
// multiset 前提:
// x の最初の 1 個だけ消す
template <class Set, class T>
inline bool erase_first(Set& s, const T& x) {
auto it = s.lower_bound(x);
if (it == s.end() || *it != x) return false;
s.erase(it);
return true;
}
// multiset 前提:
// x の最後の 1 個だけ消す
template <class Set, class T>
inline bool erase_last(Set& s, const T& x) {
auto it = s.upper_bound(x);
if (it == s.begin()) return false;
--it;
if (*it != x) return false;
s.erase(it);
return true;
}
// multiset 前提:
// x の個数
template <class Set, class T>
inline std::size_t count_equal(const Set& s, const T& x) {
auto L = s.lower_bound(x);
auto R = s.upper_bound(x);
return std::distance(L, R);
}
// ===== 最近傍 =====
// multiset の場合、同値が複数あればどれか 1 つを返す
template <class Set, class T>
inline typename Set::const_iterator it_closest(const Set& s, const T& x) {
if (s.empty()) return s.end();
auto r = s.lower_bound(x);
if (r == s.begin()) return r;
if (r == s.end()) return std::prev(r);
auto l = std::prev(r);
if (x - *l <= *r - x) return l;
return r;
}
}
#endif // KWM_T_STL_SORTED_SET_SAFE_HPP
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int q; cin >> q;
while (q--) {
int n, m; cin >> n >> m;
vector<P>gs(m);
rep(i, m) cin >> gs[i].second;
rep(i, m)cin >> gs[i].first;
sort(all(gs));
bool chk = true;
rep(i, m - 1) {
if (gs[i].second > gs[i + 1].second)chk = false;
}
cout << (chk ? "Yes" : "No") << endl;
}
return 0;
}
kwm_t