제출 #577596

#제출 시각아이디문제언어결과실행 시간메모리
577596Ronin13Poklon (COCI17_poklon)C++14
140 / 140
2091 ms17140 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; struct mo{ int l, r, ind; int bl; mo(int l, int r, int ind) : l(l), r (r), ind(ind){ bl = (l - 1) / 500; } mo(){ l = r = ind = 0; bl = 0; } }; bool operator < (mo a, mo b){ return a.bl < b.bl || (a.bl == b.bl && a.r < b.r); } vector <mo> qv; int used[1000001]; int a[1000001]; int good; void add(int ind){ int x = a[ind]; if(used[x] == 2) good--; used[x]++; if(used[x] == 2) good++; } void rem(int ind){ int x = a[ind]; if(used[x] == 2) good--; used[x]--; if(used[x] == 2) good++; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int q; cin >> q; int b[n + 1]; map <int,int> mp; for(int i= 1; i <= n; i++){ cin >> a[i]; b[i] = a[i]; } sort(b + 1, b + 1 + n); for(int i = 1; i <= n; i++){ mp[b[i]] = i; } for(int i = 1; i <= n; i++){ a[i] = mp[a[i]]; } int mo_l, mo_r; mo_l = 1, mo_r = 0; for(int i = 1; i <= q; i++){ int l, r; cin >> l >> r; qv.epb(l, r, i); } sort(qv.begin(), qv.end()); vector <int> ans(q + 1); for(int i = 0; i < qv.size(); i++){ int l = qv[i].l, r = qv[i].r, ind = qv[i].ind; while(mo_r < r){ mo_r++; add(mo_r); } while(mo_r > r){ rem(mo_r); mo_r--; } while(mo_l < l){ rem(mo_l); mo_l++; } while(mo_l > l){ mo_l--; add(mo_l); } ans[ind] = good; } for(int i= 1; i <= q; i++) cout << ans[i] << "\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

poklon.cpp: In function 'int main()':
poklon.cpp:73:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<mo>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for(int i = 0; i < qv.size(); i++){
      |                    ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...