結果
問題 |
No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
|
ユーザー |
![]() |
提出日時 | 2025-09-06 14:00:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 2,197 bytes |
コンパイル時間 | 3,812 ms |
コンパイル使用メモリ | 253,500 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-06 14:00:24 |
合計ジャッジ時間 | 4,688 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; using ll = long long; ll INF = 2e18; template<typename T> using vc = vector<T>; template<typename T> using vv = vc<vc<T>>; using vi = vc<int>; using vvi = vv<int>; using vl = vc<ll>; using vvl = vv<ll>; using vs = vc<string>; using vvs = vv<string>; using vb = vc<bool>; using vvb = vv<bool>; using vmint = vc<mint>; using vvmint = vv<mint>; #define rep(i,n) for(ll i=0; i<(n); i++) #define drep(i,n) for(ll i=(n)-1; i>=0; i--) #define rrep(i,n) for(ll i=1; i<=(n); i++) #define nfor(i,a,b) for(ll i=a;i<b;i++) #define dfor(i,a,b) for(ll i=(a)-1; i>=(b); i--) template<class T>istream& operator>>(istream& i, vc<T>& v) {rep(j,(ll) size(v))i >> v[j]; return i; } #define nall(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; } template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; } #define YES cout<<"Yes"<<endl #define NO cout<<"No"<<endl #define YN {YES;}else{NO;} #define ERROR cout<<-1<<endl void print(long double x){ printf("%.20Lf\n",x);} #define vc_cout(v){ll n = size(v);rep(i,n)cout<<v[i]<<endl;} #define vv_cout(v){ll n = size(v);rep(i,n){rep(j,size(v[i])){cout<<' '<<v[i][j];}cout<<endl;}} int main(){ int N; cin >> N; vi vec(N,0); for (int i = 0; i < N; i++) vec[i] = i; vi L(N),R(N); rep(i,N) { cin >> L[i] >> R[i]; } ll ans = 0; do { bool ok = true; rep(i,N-1) { if(L[vec[i]]>R[vec[i+1]]) ok = false; } if(ok) { bool ok2 = true; int bef = 0; vi temp(N); rep(i,N) { if(bef>R[vec[i]]) { ok2 = false; break; } else { temp[i] = max(bef,L[vec[i]]); bef = temp[i]; } } if(ok2) { ans++; } } } while (next_permutation(vec.begin(), vec.end())); cout << ans << endl; }