結果

問題 No.1244 Black Segment
ユーザー 👑 tute7627tute7627
提出日時 2020-02-11 04:18:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,295 bytes
コンパイル時間 3,503 ms
コンパイル使用メモリ 166,824 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 02:07:58
合計ジャッジ時間 5,495 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 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 168 ms
5,376 KB
testcase_05 AC 176 ms
5,376 KB
testcase_06 AC 179 ms
5,376 KB
testcase_07 AC 186 ms
5,376 KB
testcase_08 AC 180 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 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 54 ms
5,376 KB
testcase_21 AC 54 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 59 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 58 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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(int i = (n); i < (int)(m); i++)
#define rrep(i,n,m) for(int i = (m) - 1; i >= (int)(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<50>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