QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#833995#8907. Конференцияxlwang0 0ms0kbC++143.3kb2024-12-27 09:43:202024-12-27 09:43:21

Judging History

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

  • [2024-12-27 09:43:21]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-12-27 09:43:20]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
#define pii pair<int,int>
#define mk make_pair
using namespace std;
inline int read(){
	int x=0;
	bool f=0;
	char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
inline void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
const int Maxn=1e5+10;
struct node{
    pii l;
    int id;
}e[Maxn];
int n;
inline bool cmp1(node A,node B){return A.l.second<B.l.second;}
inline bool cmp2(node A,node B){return A.l.first>B.l.first;}
int chs[Maxn],vis[Maxn];
inline void clear(){fr(i,1,n) vis[i]=chs[i]=0;}
inline void work(){
    n=read();
    fr(i,1,n) e[i].l.first=read(),e[i].l.second=read(),e[i].id=i;
    // fr(i,30,min(n,49)) cout<<e[i].l.first<<' '<<e[i].l.second<<endl;
    int m=0;sort(e+1,e+n+1,cmp1);
    int lst=0;
    fr(i,1,n){
        if(lst<e[i].l.first) ++m,lst=e[i].l.second;
    }
    // cout<<m<<endl;
    int now=0;lst=0;
    int _n=0;
    fr(i,1,n){
        if(lst<e[i].l.first){
            ++now;
            chs[e[i].id]=vis[e[i].id]=1;
            ++_n;
            lst=e[i].l.second;
            if(now==(m/2)){
                fr(j,i+1,n) if(e[j].l.first<=lst) ++_n,chs[e[j].id]=1;
                break; 
            }
        }
        else {
            chs[e[i].id]=1;
            ++_n;
        }
    }
    // cout<<m<<endl;
    // cout<<_n<<endl;
    if(now==m/2 && _n>=n/2){
        fr(i,1,n){
            if(_n==(n/2)) break;
            if(!chs[i]) continue;
            if(vis[i]) continue;
            chs[i]=0;--_n;
        }
        fr(i,1,n) if(chs[i]) writepl(i);puts("");
        clear();
        return;
    }
    now=lst=_n=0;
    sort(e+1,e+n+1,cmp2);
    
    // fr(i,1,n) cout<<e[i].l.first<<' '<<e[i].l.second<<endl;
    lst=2e9;clear();
    fr(i,1,n){
        if(e[i].l.second<lst){
            ++now;
            chs[e[i].id]=vis[e[i].id]=1;
            ++_n;
            lst=e[i].l.first;
            if(now==m/2){
                fr(j,i+1,n) if(e[i].l.second>=lst) ++_n,chs[e[j].id]=1;
                break;
            }
        }
        else {
            chs[e[i].id]=1;
            ++_n;
        }
    }
    // cout<<_n<<endl;
    if(now==m/2 && _n>=n/2){
        fr(i,1,n){
            if(_n==(n/2)) break;
            if(!chs[i]) continue;
            if(vis[i]) continue;
            chs[i]=0;--_n;
        }
        fr(i,1,n) if(chs[i]) writepl(i);puts("");
        clear();
        return;
    }
}
inline void init(){
	int t=read();
	while(t--) work();
}
signed main(){
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
    init();
    // printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

详细

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 0
Dangerous Syscalls

input:

1
4
823983109 859315505
510901709 589624124
351308325 413158126
29447781 138101981

output:


result:


Subtask #2:

score: 0
Dangerous Syscalls

Test #9:

score: 0
Dangerous Syscalls

input:

1
10
4 6
15 20
1 12
11 16
3 10
13 19
5 18
7 8
2 17
9 14

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Dangerous Syscalls

Test #39:

score: 0
Dangerous Syscalls

input:

1
10
8 9
15 18
12 13
5 14
7 10
1 20
2 19
6 11
3 4
16 17

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #2:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%