結果

問題 No.1244 Black Segment
ユーザー 👑 tute7627tute7627
提出日時 2020-02-11 04:21:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,291 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 168,816 KB
実行使用メモリ 10,140 KB
最終ジャッジ日時 2024-04-17 02:08:07
合計ジャッジ時間 6,438 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,576 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 166 ms
5,376 KB
testcase_05 AC 165 ms
5,376 KB
testcase_06 AC 171 ms
5,376 KB
testcase_07 AC 172 ms
5,376 KB
testcase_08 AC 179 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e9+1;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
int main(){
	int n,m,a,b;cin>>n>>m>>a>>b;
	a--;b--;
	vector<int>l(m),r(m);
	rep(i,0,m){
		cin>>l[i]>>r[i];
		l[i]--;r[i]--;
	}
	int res=INF;
	ll m2=min(m,60);
	rep(i,0,1LL<<m2){
		bitset<60>x=i;
		vector<int>k(n+1);
		rep(j,0,m){
			if(x[j]){
				rep(o,l[j],r[j]+1)k[o]^=1;
			}
		}
		int cnt=0;
		rep(j,0,n)if(k[j]==1&&k[j+1]==0)cnt++;
		if(cnt>=2)continue;
		if(k[a]&&k[b])chmin(res,__builtin_popcount(i));
	}
	if(res==INF)cout<<-1<<endl;
	else cout<<res<<endl;
  return 0;
}
0