結果
問題 | No.1170 Never Want to Walk |
ユーザー | Cinnamoroll |
提出日時 | 2020-08-15 08:54:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 326 ms / 2,000 ms |
コード長 | 7,359 bytes |
コンパイル時間 | 1,899 ms |
コンパイル使用メモリ | 178,188 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-10-10 17:18:10 |
合計ジャッジ時間 | 7,820 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 37 |
ソースコード
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ ███████████████████ // #include "bits/stdc++.h" using namespace std; #define INF (1<<30) #define LINF (1LL<<60) #define fs first #define sc second #define int long long #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FOR2(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i) #define RFOR2(i,a,b) for(int i = (b);i>=(a);--i) #define REP(i,n) FOR(i,0,(n)) #define REP2(i,n) FOR2(i,0,(n)) #define RREP(i,n) RFOR(i,0,(n)) #define RREP2(i,n) RFOR2(i,0,(n)) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i,a,b) ((a)<=(i) && (i)<(b)) #define debug(x) cout << #x << " = " << (x) << endl #define SP << " " << template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b) {a=b; return true;} else return false;} template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b) {a=b; return true;} else return false;} #define MSB(x) (63-__builtin_clzll(x)) #define pcnt(x) (__builtin_popcountll(x)) #define parity(i,j) (i&(1LL<<j)) typedef pair<int,int> P; typedef tuple<int,int,int> T; typedef vector<int> vec; typedef vector<vector<int>> mat; struct UnionFind { private: vector<int> child,tree; vector<vector<int>> list; public: UnionFind(int v) { tree.resize(v); list.resize(v); REP(i,v) tree[i] = i, list[i].push_back(i); } int root(int i){ if(i == tree[i]){ REP(j,child.size()) tree[child[j]] = i; child.clear(); return i; } else{ child.push_back(i); return i = root(tree[i]); } } int size(int i){ return list[root(i)].size(); } vector<int> nodes(int no){ return list[root(no)]; } bool unit(int x, int y){ x = root(x); y = root(y); if(x==y) return false; if(list[x].size() < list[y].size()) swap(x,y); for(int no:list[y]) list[x].emplace_back(no); tree[y] = x; return true; } bool isUnit(int x, int y){ return root(x) == root(y); } }; void solve(){ int N,A,B; cin >> N >> A >> B; vector<int> a(N); REP(i,N) cin >> a[i]; UnionFind uf(N); REP(i,N){ int l = lower_bound(a.begin(),a.end(),a[i]+A) - a.begin(); int r = upper_bound(a.begin(),a.end(),a[i]+B) - a.begin() - 1; if(l>r) continue; uf.unit(i,l); uf.unit(i,r); RFOR(j,l,r-1) if(!uf.unit(j,j+1)) break; } REP(i,N) cout << uf.size(i) << endl; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); int T = 1; // cin >> T; while(T--) solve(); return 0; }