QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#756522 | #8672. 排队 | Sham_Devour | Compile Error | / | / | C++14 | 5.5kb | 2024-11-16 20:48:33 | 2024-11-16 20:48:39 |
Judging History
answer
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,popcnt,tune=native")
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define lson p << 1
#define rson p << 1 | 1
using namespace std;
const int N = 1e6 + 5;
struct freader {
FILE *f;
# ifdef ONLINE_JUDGE
char buf[1048577], *p1, *p2;
# define fgetc(f) (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1048576, f), p1 == p2) ? EOF : *p1++)
# endif
# ifdef BOOLTRANS
bool neof;
# define NEOF(c) ((c) != EOF || (neof = 0))
# else
# define NEOF(c) ((c) != EOF)
# endif
freader(FILE *_f = stdin) : f(_f) {
# ifdef BOOLTRANS
neof = 1;
# endif
# ifdef ONLINE_JUDGE
setvbuf(f, NULL, _IONBF, 0);
p1 = p2 = buf;
# endif
}
void read(char &x) {
for (x = fgetc(f); NEOF(x) && x <= ' '; x = fgetc(f));
return;
}
void read(char *s) {
for (*s = fgetc(f); NEOF(*s) && *s <= ' '; *s = fgetc(f));
for (s++; NEOF(*s = fgetc(f)) && *s > ' '; s++);
*s = '\0';
return;
}
void read(float x) {return fputs("Error: Unable to read float.", stderr), void();}
void read(double x) {return fputs("Error: Unable to read double.", stderr), void();}
void read(long double x) {return fputs("Error: Unable to read long double.", stderr), void();}
template<typename T> void read(T &x) {
char c(fgetc(f));
# ifdef NEGATIVE
for (; NEOF(c) && (c < '0' || c > '9') && c != '-'; c = fgetc(f));
if (c == '-')
for (c = fgetc(f), x = 0; NEOF(c) && c >= '0' && c <= '9'; c = fgetc(f)) x = (x << 3) + (x << 1) - (c ^ '0');
else
for (x = 0; NEOF(c) && c >= '0' && c <= '9'; c = fgetc(f)) x = (x << 3) + (x << 1) + (c ^ '0');
# else
for (; NEOF(c) && (c < '0' || c > '9'); c = fgetc(f));
for (x = 0; NEOF(c) && c >= '0' && c <= '9'; c = fgetc(f)) x = (x << 3) + (x << 1) + (c ^ '0');
# endif
return;
}
# if __cplusplus >= 201103
template<typename T, typename...Args> void read(T &x, Args &...args) {return read(x), read(args...);}
# endif
template<typename T> freader &operator >> (T &x) {
# ifdef BOOLTRANS
return *this ? read(x), *this : *this;
# else
return read(x), *this;
# endif
}
# ifdef BOOLTRANS
operator bool() {return neof;}
# endif
# ifdef ONLINE_JUDGE
# undef fgetc
# endif
# undef NEOF
} fin;
struct fwriter {
FILE *f;
# ifdef ONLINE_JUDGE
char buf[1048577], *p1;
# define fputc(c, f) (p1 == buf + 1048576 ? fwrite(buf, 1, 1048576, f), *(p1 = buf)++ = (c) : *p1++ = (c))
# endif
fwriter(FILE *_f = stdout): f(_f) {
# ifdef ONLINE_JUDGE
setvbuf(f, NULL, _IONBF, 0);
p1 = buf;
# endif
}
~fwriter() {flush();}
void flush() {
# ifdef ONLINE_JUDGE
fwrite(buf, 1, p1 - buf, f), p1 = buf;
# else
fflush(f);
# endif
return;
}
void write(char c) {return fputc(c, f), void();}
void write(char *s) {
for (; *s; s++) fputc(*s, f);
return;
}
void write(const char *s) {
for (; *s; s++) fputc(*s, f);
return;
}
void write(float x) {return fputs("Error: Unable to write float.", stderr), void();}
void write(double x) {return fputs("Error: Unable to write double.", stderr), void();}
void write(long double x) {return fputs("Error: Unable to write long double.", stderr), void();}
template<typename T> void write(T x) {
if (!x) return fputc('0', f), void();
if (x < 0) fputc('-', f), x = -x;
char s[41];
int l(0);
while (x) s[l++] = x % 10 ^ '0', x /= 10;
while (l--) fputc(s[l], f);
return;
}
# if __cplusplus >= 201103
template<typename T, typename...Args> void write(T x, Args...args) {return write(x), write(args...);}
# endif
template<typename T> fwriter &operator << (T x) {return write(x), *this;}
# ifdef ONLINE_JUDGE
# undef fputc
# endif
} fout;
int n, q, ans[N];
pii a[N];
vector<pii> vq[N];
int vl[N << 2], vr[N << 2], lazy[N << 2];
void pushup(int p) {
vl[p] = vl[lson];
vr[p] = vr[rson];
}
void pushdown(int p) {
if (!lazy[p]) return;
vl[lson] += lazy[p], vl[rson] += lazy[p];
vr[lson] += lazy[p], vr[rson] += lazy[p];
lazy[lson] += lazy[p], lazy[rson] += lazy[p];
lazy[p] = 0;
}
void update(int p, int L, int R, int l, int r) {
if (l <= L && r >= R) {
vl[p]++, vr[p]++, lazy[p]++;
return;
}
pushdown(p);
int mid = L + R >> 1;
if (l <= mid) update(lson, L, mid, l, r);
if (r > mid) update(rson, mid + 1, R, l, r);
pushup(p);
}
int findL(int p, int L, int R, int x) {
if (vr[p] > x) return -1;
if (L == R) return L;
pushdown(p);
int mid = L + R >> 1;
if (vr[lson] <= x) return findL(lson, L, mid, x);
return findL(rson, mid + 1, R, x);
}
int findR(int p, int L, int R, int x) {
if (vl[p] < x) return -1;
if (L == R) return L;
pushdown(p);
int mid = L + R >> 1;
if (vl[rson] >= x) return findR(rson, mid + 1, R, x);
return findR(lson, L, mid, x);
}
int query(int p, int L, int R, int x) {
if (L == R) return vl[p];
pushdown(p);
int mid = L + R >> 1;
if (x <= mid) return query(lson, L, mid, x);
return query(rson, mid + 1, R, x);
}
int main() {
fin >> n >> q;
for (int i = 1; i <= n; i++) fin >> a[i].fi >> a[i].se;
for (int i = 1; i <= q; i++) {
int l, r;
fin >> l >> r;
vq[r].push_back(mp(l, i));
}
for (int i = 1; i <= n; i++) {
int lp = findL(1, 1, n, a[i].se), rp = min(findR(1, 1, n, a[i].fi), i);
if (lp != -1 && rp != -1 && lp <= rp) update(1, 1, n, lp, rp);
for (auto j : vq[i]) ans[j.se] = query(1, 1, n, j.fi);
}
for (int i = 1; i <= q; i++) fout << ans[i] << '\n';
return 0;
}
詳細信息
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/gthr.h:148, from /usr/include/c++/13/ext/atomicity.h:35, from /usr/include/c++/13/bits/ios_base.h:39, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from answer.code:4: /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 102 | __gthrw(pthread_once) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 103 | __gthrw(pthread_getspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 104 | __gthrw(pthread_setspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 106 | __gthrw(pthread_create) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 107 | __gthrw(pthread_join) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 108 | __gthrw(pthread_equal) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 109 | __gthrw(pthread_self) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 110 | __gthrw(pthread_detach) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 112 | __gthrw(pthread_cancel) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 114 | __gthrw(sched_yield) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 116 | __gthrw(pthread_mutex_lock) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 117 | __gthrw(pthread_mutex_trylock) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 119 | __gthrw(pthread_mutex_timedlock) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:121:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 121 | __gthrw(pthread_mutex_unlock) |...