提出 #61171841
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define LagaKar ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ook order_of_key //number of elements less than k
#define fbo find_by_order //k th element (0 index)
#define nline endl
#define YES cout<<"YES"<<nline
#define NO cout<<"NO"<<nline
#define Yes cout<<"Yes"<<nline
#define No cout<<"No"<<nline
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#define precise(ans) cout<<fixed<<setprecision(15)<<ans
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define Tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define Sz(x) ((ll)(x).size())
#define All(x) x.begin(), x.end()
#define Allr(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(All(x))
#define MIN(x) *min_element(All(x))
#define SUM(x) accumulate(All(x), 0LL)
#define CNT(x) __builtin_popcountll(x)
//##################################################################################################################
typedef long long ll; typedef unsigned long long ull; typedef long double lld;
typedef pair<ll, ll> pl; typedef vector<ll> vl;typedef vector<vl> vvl;
typedef vector<pl> vpl; template <typename T> using prq_mx = priority_queue<T>;
template <typename T> using prq_mn = priority_queue<T, vector<T>, greater<T>>;
//------------------------------------------------------------------------------------------------------------
template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename R> using o_map = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using o_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
//********************************************************************************************************************
#ifdef hydracody
#include </home/anurag/Desktop/cpc/debug.h>
#else
#define debug(x)
#endif
//------------------------------------------------------------------------------------------------------------
const double eps=1e-9;const ll INF=(ll)1e9;const ll inf64=2e18;const ll INF64=9e18;
#define PI 3.1415926535897932384626
#define MOD 998244353
#define MOD1 1000000007
#define MOD2 1000000009
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
ll power(ll x,ll y, ll p){if(y==0)return 1;ll res = 1;x = x % p;if (x == 0) return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
ll pinv(ll a, ll m){ return power(a, m - 2, m); }
ll logceil(ll x){ll s=0;while(x>0){s++;x=x/2;}return s;}
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, pinv(b, m), m) + m) % m;} //only for prime m
ll phin(ll n) {ll number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0) n /= 2;} for (ll i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))
ll getRandomNumber(ll l, ll r) {return uniform_int_distribution<ll>(l, r)(rng);}
void starter(ll t) {cout << "Case #" << t << ": ";}
void starter1(ll t) {cerr << "Case #" << t << ": ";}
void compress(vector<ll>& vs){sort(vs.begin(),vs.end());vs.resize(unique(vs.begin(), vs.end()) - vs.begin());}
/////////////////////////////////////////////////////////////////////////////////////////////////
// **Stay calm ,Believe in YOURSELF,Never give UP
// **Not Everyday is Yours
void chal(){
ll n,m;
cin>>n>>m;
vpl bb;
vpl r,c;
fo(i,m){
ll u,v;
char ch;
cin>>u>>v>>ch;
if(ch=='B'){
r.pb({u,v});
c.pb({v,u});
}else bb.pb({u,v});
}
sort(All(r));
sort(All(c));
ll x=0;
for(ll i=Sz(r)-1;i>=0;i--){
x=max(x,r[i].se);
r[i].se=x;
}
x=0;
for(ll i=Sz(c)-1;i>=0;i--){
x=max(x,c[i].se);
c[i].se=x;
}
fo(i,Sz(bb)){
ll u=bb[i].fi,v=bb[i].se;
auto it1=lb(All(r),mp(u,0ll));
auto it2=lb(All(c),mp(v,0ll));
if(it1!=r.end() && (*it1).se>=v){
No;
return;
}
if(it2!=c.end() && (*it2).se>=u){
No;return;
}
}
Yes;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int32_t main() {
LagaKar;
#ifdef hydracody
freopen("input.txt", "r", stdin); freopen("output1.txt", "w", stdout); freopen("error.txt", "w", stderr);
#endif
ll t; t = 1;
// cin>>t;
for (ll i = 1; i <= t; i++) {
// starter(i);
chal();
}
return 0;
}
/*
cmd->g++ code1.cpp ./a.out
*/
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
425 / 425 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt, 01_test_45.txt, 01_test_46.txt, 01_test_47.txt, 01_test_48.txt, 01_test_49.txt, 01_test_50.txt, 01_test_51.txt, 01_test_52.txt, 01_test_53.txt, 01_test_54.txt, 01_test_55.txt, 01_test_56.txt, 01_test_57.txt, 01_test_58.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
1 ms |
3644 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3504 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3512 KiB |
| 00_sample_03.txt |
AC |
1 ms |
3448 KiB |
| 01_test_00.txt |
AC |
1 ms |
3676 KiB |
| 01_test_01.txt |
AC |
1 ms |
3460 KiB |
| 01_test_02.txt |
AC |
1 ms |
3404 KiB |
| 01_test_03.txt |
AC |
1 ms |
3672 KiB |
| 01_test_04.txt |
AC |
58 ms |
7944 KiB |
| 01_test_05.txt |
AC |
51 ms |
7648 KiB |
| 01_test_06.txt |
AC |
43 ms |
7500 KiB |
| 01_test_07.txt |
AC |
14 ms |
4520 KiB |
| 01_test_08.txt |
AC |
25 ms |
5508 KiB |
| 01_test_09.txt |
AC |
21 ms |
5436 KiB |
| 01_test_10.txt |
AC |
44 ms |
7996 KiB |
| 01_test_11.txt |
AC |
28 ms |
6304 KiB |
| 01_test_12.txt |
AC |
43 ms |
8068 KiB |
| 01_test_13.txt |
AC |
14 ms |
4676 KiB |
| 01_test_14.txt |
AC |
69 ms |
8148 KiB |
| 01_test_15.txt |
AC |
60 ms |
7460 KiB |
| 01_test_16.txt |
AC |
70 ms |
8100 KiB |
| 01_test_17.txt |
AC |
38 ms |
6028 KiB |
| 01_test_18.txt |
AC |
44 ms |
7928 KiB |
| 01_test_19.txt |
AC |
12 ms |
4468 KiB |
| 01_test_20.txt |
AC |
57 ms |
8120 KiB |
| 01_test_21.txt |
AC |
27 ms |
5376 KiB |
| 01_test_22.txt |
AC |
65 ms |
8168 KiB |
| 01_test_23.txt |
AC |
12 ms |
4516 KiB |
| 01_test_24.txt |
AC |
63 ms |
8104 KiB |
| 01_test_25.txt |
AC |
17 ms |
4464 KiB |
| 01_test_26.txt |
AC |
50 ms |
7988 KiB |
| 01_test_27.txt |
AC |
45 ms |
7248 KiB |
| 01_test_28.txt |
AC |
63 ms |
8348 KiB |
| 01_test_29.txt |
AC |
24 ms |
5552 KiB |
| 01_test_30.txt |
AC |
59 ms |
9772 KiB |
| 01_test_31.txt |
AC |
32 ms |
6464 KiB |
| 01_test_32.txt |
AC |
26 ms |
7376 KiB |
| 01_test_33.txt |
AC |
14 ms |
5352 KiB |
| 01_test_34.txt |
AC |
64 ms |
8260 KiB |
| 01_test_35.txt |
AC |
51 ms |
7664 KiB |
| 01_test_36.txt |
AC |
65 ms |
8120 KiB |
| 01_test_37.txt |
AC |
13 ms |
4432 KiB |
| 01_test_38.txt |
AC |
56 ms |
8108 KiB |
| 01_test_39.txt |
AC |
29 ms |
6348 KiB |
| 01_test_40.txt |
AC |
58 ms |
8188 KiB |
| 01_test_41.txt |
AC |
18 ms |
4984 KiB |
| 01_test_42.txt |
AC |
62 ms |
9740 KiB |
| 01_test_43.txt |
AC |
12 ms |
4808 KiB |
| 01_test_44.txt |
AC |
26 ms |
7400 KiB |
| 01_test_45.txt |
AC |
13 ms |
5368 KiB |
| 01_test_46.txt |
AC |
65 ms |
8112 KiB |
| 01_test_47.txt |
AC |
18 ms |
4784 KiB |
| 01_test_48.txt |
AC |
53 ms |
8116 KiB |
| 01_test_49.txt |
AC |
36 ms |
7244 KiB |
| 01_test_50.txt |
AC |
62 ms |
7932 KiB |
| 01_test_51.txt |
AC |
30 ms |
6268 KiB |
| 01_test_52.txt |
AC |
54 ms |
8304 KiB |
| 01_test_53.txt |
AC |
48 ms |
7376 KiB |
| 01_test_54.txt |
AC |
65 ms |
8148 KiB |
| 01_test_55.txt |
AC |
6 ms |
3880 KiB |
| 01_test_56.txt |
AC |
49 ms |
8148 KiB |
| 01_test_57.txt |
AC |
10 ms |
4424 KiB |
| 01_test_58.txt |
AC |
1 ms |
3500 KiB |