{"push_id":2860825794,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"3c52e059cc9fd98065d0e995dc783ea0f3625594","before":"414698341c1caa6ca3e387861a51b52c0a830498","commits":[{"sha":"3c52e059cc9fd98065d0e995dc783ea0f3625594","author":{"name":"Lúcio Cardoso","email":"9bdae36f9246badb36a5cb06057a42951e2fee55@gmail.com"},"message":"Adicionado #include <bits/stdc++.h>  using namespace std;  const int MAXN = 5e5+10; const int BUCKET = 810;  struct Q  { \tint l, r, bloco, id; } q[MAXN];  int freq[MAXN], ans[MAXN], num[MAXN], block[BUCKET], s;  bool comp(Q a, Q b) { \tif (a.bloco == b.bloco) \t{ \t\tif (a.bloco%2) return a.r < b.r; \t\treturn a.r > b.r; \t} \treturn a.bloco < b.bloco; }  inline int scan(void) { \tint n = 0, x = getchar(), s =1;  \tfor (;x<'0'||x>'9';x=getchar()) if(x=='-') s=-1; \tfor (;x>='0'&&x<='9';x=getchar()) n = (n<<3) + (n<<1) + x-'0'; \treturn n; }  int main(void) { \tint n; \tn = scan();  \tfor (int i = 0; i < n; i++) \t\tnum[i] = scan();  \tint m; \ts = sqrt(n); \tm = scan();  \tfor (int i = 0; i < m; i++) \t{ \t\tq[i].l = scan(), q[i].r = scan(); \t\tq[i].l--, q[i].r--; \t\tq[i].bloco = q[i].l/s, q[i].id = i; \t}  \tsort(q, q+m, comp);  \tint l = 0, r = 0; \tfreq[num[0]] = 1; \tblock[num[0]/s]++;  \tfor (int i = 0; i < m; i++) \t{ \t\twhile (r > q[i].r) \t\t{ \t\t\tint pos = num[r]/s; \t\t\tfreq[num[r]]--; \t\t\tif (!freq[num[r]]) block[pos]--; \t\t\tif (freq[num[r]] == 1) block[pos]++; \t\t\tr--; \t\t} \t\twhile (r < q[i].r) \t\t{ \t\t\tfreq[num[++r]]++; \t\t\tint pos = num[r]/s; \t\t\tif (freq[num[r]] == 1) block[pos]++; \t\t\tif (freq[num[r]] == 2) block[pos]--; \t\t}  \t\twhile (l > q[i].l) \t\t{ \t\t\tfreq[num[--l]]++; \t\t\tint pos = num[l]/s; \t\t\tif (freq[num[l]] == 1) block[pos]++; \t\t\tif (freq[num[l]] == 2) block[pos]--; \t\t} \t\twhile (l < q[i].l) \t\t{ \t\t\tint pos = num[l]/s; \t\t\tfreq[num[l]]--; \t\t\tif (!freq[num[l]]) block[pos]--; \t\t\tif (freq[num[l]] == 1) block[pos]++; \t\t\tl++; \t\t}  \t \t\tint k = l/s, p = r/s; \t\tfor (int b = 0; b < BUCKET; b++) \t\t{ \t\t\tif (block[b] > 0) \t\t\t{ \t\t\t\tfor (int j = b*s; j < (b+1)*s; j++) \t\t\t\t{ \t\t\t\t\tif (freq[j] == 1) \t\t\t\t\t{ \t\t\t\t\t\tans[q[i].id] = j; \t\t\t\t\t\tbreak; \t\t\t\t\t} \t\t\t\t} \t\t\t\tbreak; \t\t\t} \t\t} \t}  \tfor (int i = 0; i < m; i++) \t\tprintf(\"%d\\n\", ans[i]); }","distinct":true,"url":"https://api.github.com/repos/luciocf/Problemas/commits/3c52e059cc9fd98065d0e995dc783ea0f3625594"}]}
{"actor":{"display_login":"luciocf"}}