QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#420499#8672. 排队QZJ123456Compile Error//C++145.7kb2024-05-24 19:26:512024-05-24 19:26:51

Judging History

你现在查看的是最新测评结果

  • [2024-05-24 19:26:51]
  • 评测
  • [2024-05-24 19:26:51]
  • 提交

answer

#include <cstdio>
#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<bits/stdc++.h>
using namespace std;
#define NEGATIVE
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,l[1000005],r[1000005];
struct node{
	int p,id;
	node(int p_,int id_){
		p=p_,id=id_;
	}
};
vector<node>vec[1000005];
struct Seg{
	int l,r,mx,lazy;
}Tree[4000005];
int ans[1000005];
void ztree(int p,int l,int r){
	Tree[p].l=l,Tree[p].r=r,Tree[p].mx=Tree[p].lazy=0;
	if(l==r)return;
	int mid=l+r>>1;
	ztree(p*2,l,mid);
	ztree(p*2+1,mid+1,r);
}
void pushdown(int p){
	if(Tree[p].lazy==0)return;
	Tree[p*2].lazy+=Tree[p].lazy;
	Tree[p*2+1].lazy+=Tree[p].lazy;
	Tree[p*2].mx+=Tree[p].lazy;
	Tree[p*2+1].mx+=Tree[p].lazy;
	Tree[p].lazy=0;
}
void upd(int p,int l,int r){
	if(l>r)return;
	if(l<=Tree[p].l&&Tree[p].r<=r){
		Tree[p].mx++;
		Tree[p].lazy++;
		return;
	}
	pushdown(p);
	int mid=Tree[p].l+Tree[p].r>>1;
	if(l<=mid)upd(p*2,l,r);
	if(r>mid)upd(p*2+1,l,r);
	Tree[p].mx=Tree[p*2].mx;
}
int Get(int p,int l){
	if(Tree[p].l==Tree[p].r)return Tree[p].mx;
	pushdown(p);
	int mid=Tree[p].l+Tree[p].r>>1;
	if(l<=mid)return Get(p*2,l);
	return Get(p*2+1,l);
}
int findpos(int p,int x){
	if(Tree[p].l==Tree[p].r)return Tree[p].l;
	pushdown(p);
	if(Tree[p*2].mx<x)return 0;
	if(Tree[p*2+1].mx>=x)return findpos(p*2+1,x);
	else return findpos(p*2,x);
}
int main(){
	fin.read(n,q);
	for(int i=1;i<=n;i++)fin.read(l[i],r[i]);
	for(int i=1;i<=q;i++){
		int x,y;
		fin.read(x,y);
		vec[y].push_back(node(x,i));
	}
	ztree(1,1,n);
	for(int i=1;i<=n;i++){
		int L=findpos(1,r[i]+1)+1,R;
		if(l[i]==0)R=i;
		else R=findpos(1,l[i]);
		upd(1,L,R);
		for(auto to:vec[i])ans[to.id]=Get(1,to.p);
	}
	for(int i=1;i<=q;i++)fout.write(ans[i],'\n');
	return 0;
}

Details

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/streambuf:43,
                 from /usr/include/c++/13/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/13/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:54,
                 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 ‘t...