結果

問題 No.1170 Never Want to Walk
ユーザー arahi10arahi10
提出日時 2020-08-14 22:10:42
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,801 bytes
コンパイル時間 2,400 ms
コンパイル使用メモリ 162,180 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-18 22:00:54
合計ジャッジ時間 7,746 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,984 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 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 9 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 9 ms
5,376 KB
testcase_25 AC 8 ms
5,376 KB
testcase_26 AC 6 ms
5,376 KB
testcase_27 AC 112 ms
5,376 KB
testcase_28 AC 114 ms
5,376 KB
testcase_29 AC 115 ms
5,376 KB
testcase_30 AC 114 ms
5,376 KB
testcase_31 AC 112 ms
5,376 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
/* S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
__gcd() lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
clock()/CLOCKS_PER_SEC で秒数
vector v.push_back(x),v.pop_back()
q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
<deque>(push/pop)_(front/back)/fornt/back/insert/
priority_queue 宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに*/
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repl(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;(i)--)
#define vep(i,v) for(auto (i)=v.begin();(i)<(v.end());(i)++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
typedef pair<int,int> PI;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<std::vector<long long>> vvl;
typedef std::vector<char> vc;
typedef std::vector<std::vector<char>> vvc;
typedef std::vector<long long> vl;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
using Graph = std::vector<std::vector<int> >;
const long long inf = 10e17;
const long long mod = 1000000007;
//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
#define print(i) std::cout << (i) << '\n'
struct union_find{

    std::vector<int> table;
    int Size;
    union_find(int si):table(si,-1){Size=si;}
    int find(int x){return table.at(x)<0? x:table.at(x)=find(table.at(x));}
    int size(int x){return -table.at(find(x));}
    bool unite(int x,int y){
        x=find(x);y=find(y);
        if (x==y)return false;
        if (table.at(x)>table.at(y))std::swap(x,y);
        table.at(x)+=table.at(y);
        table.at(y)=x;return true;}
    bool same(int x,int y){return find(x)==find(y);}
    
    };

int main(){
int n,a,b;cin>>n>>a>>b;
union_find uf(n);
vi l(n);rep(i,n)cin>>l[i];
int left=0,right=0;
rep(i,n){
    int x=l[i];
    while(left<n && l[left]<x-b)left++;
    while(left<n && l[right]<=x-a)right++;
    for (int j=left;j<right;j++)uf.unite(i,j);
}
rep(i,n)print(uf.size(i));
}
0