# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103020 | 2019-03-28T18:57:39 Z | rzbt | Poklon (COCI17_poklon) | C++14 | 564 ms | 42232 KB |
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 500005 using namespace std; int n,q; int niz[MAXN]; set<int> s; map<int,int> m; int prosli[MAXN]; int proslix[MAXN]; int bit[MAXN]; void dodaj(int p,int x){ if(p==0)return; for(;p<MAXN;p+=(-p)&p) bit[p]+=x; } int dobij(int p){ int z=0; for(;p>0;p-=(-p)&p) z+=bit[p]; return z; } int res[MAXN]; vector<pair<int,int>> omega [MAXN]; int main() { scanf("%d %d", &n, &q); for(int i=1;i<=n;i++){ scanf("%d",niz+i); s.insert(niz[i]); } int bbb=1; for(auto x:s){ m[x]=bbb; bbb++; } for(int i=1;i<=n;i++){ niz[i]=m[niz[i]]; prosli[i]=proslix[niz[i]]; proslix[niz[i]]=i; } for(int i=1;i<=q;i++){ int t1,t2; scanf("%d %d", &t1, &t2); omega[t2].pb(mp(t1,i)); } for(int i=1;i<=n;i++){ dodaj(prosli[i],1); dodaj(prosli[prosli[i]],-2); for(auto x:omega[i]) res[x.second]=dobij(i)-dobij(x.first-1); } for(int i=1;i<=q;i++)printf("%d\n",res[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 12160 KB | Output isn't correct |
2 | Incorrect | 14 ms | 12160 KB | Output isn't correct |
3 | Incorrect | 14 ms | 12416 KB | Output isn't correct |
4 | Incorrect | 16 ms | 12416 KB | Output isn't correct |
5 | Incorrect | 112 ms | 17784 KB | Output isn't correct |
6 | Incorrect | 87 ms | 17784 KB | Output isn't correct |
7 | Incorrect | 196 ms | 23952 KB | Output isn't correct |
8 | Incorrect | 337 ms | 30124 KB | Output isn't correct |
9 | Incorrect | 491 ms | 36104 KB | Output isn't correct |
10 | Incorrect | 564 ms | 42232 KB | Output isn't correct |