找不同(玄两关)

P1056 [NOIP2008 普及组] 排座椅

@[违规用户名UID1198296](/user/1198296) 发个代码。我看不见。
by xiaoshumiao @ 2024-01-24 21:36:56


@[xiaoshumiao](/user/1008513) 我的: ```cpp #include<bits/stdc++.h> using namespace std; int m,n,k,ll,d; const int N=1005; struct ccf{ int pos,num; }h[N],l[N]; bool cmp(ccf x,ccf y){ if(x.num!=y.num) return x.num>y.num; else return x.pos<y.pos; }bool cmp1(ccf x,ccf y){ return x.pos<y.pos; } int main(){ int f1,f2,l1,l2; cin>>m>>n>>k>>ll>>d; for(int i=1;i<n;++i) l[i].pos=h[i].pos=i; while(d--){ cin>>f1>>f2>>l1>>l2; if(f2!=l2){ ++l[min(f2,l2)].num; }else{ ++h[min(f1,l1)].num; } }sort(l+1,l+n+1,cmp); sort(h+1,h+n+1,cmp); sort(l+1,l+k+1,cmp1); sort(h+1,h+ll+1,cmp1); for(int i=1;i<=k;++i){ cout<<h[i].pos<<' '; } cout<<endl; for(int i=1;i<=ll;++i){ cout<<l[i].pos<<' '; } cout<<endl; return 0; } ``` 教练的: ```cpp #include<bits/stdc++.h> using namespace std; int m,n,k,ll,d; const int N=1005; struct ccf { int pos,num; } h[N],l[N]; bool cmp(ccf x,ccf y) { if(x.num!=y.num)return x.num>y.num; else return x.pos<y.pos; } bool cmp1(ccf x,ccf y) { return x.pos<y.pos; } int main() { int f1,f2,l1,l2; cin>>m>>n>>k>>ll>>d; for(int i=1;i<n;++i) l[i].pos=h[i].pos=i; while(d--) { cin>>f1>>f2>>l1>>l2; if(f2!=l2) { ++l[min(f2,l2)].num; } else { ++h[min(f1,l1)].num; } } sort(l+1,l+n,cmp); sort(h+1,h+n,cmp); sort(h+1,h+k+1,cmp1); sort(l+1,l+ll+1,cmp1); for(int i=1; i<=k; ++i) { cout<<h[i].pos<<' '; } cout<<endl; for(int i=1; i<=ll; ++i) { cout<<l[i].pos<<' '; } cout<<endl; return 0; } ```
by 违规用户名UID1198296 @ 2024-01-24 21:39:45


在线等待大佬解密
by 违规用户名UID1198296 @ 2024-01-24 21:41:45


``` sort(l+1,l+n+1,cmp); sort(h+1,h+n+1,cmp); ``` $and$ ``` sort(l+1,l+n,cmp); sort(h+1,h+n,cmp); ```
by pfrig729 @ 2024-01-24 21:44:38


@[pfrig729](/user/730178) wssb
by 违规用户名UID1198296 @ 2024-01-24 21:46:02


@[pfrig729](/user/730178) 不过还是10分 我待会再注册一个小号,悬赏提升至3关
by 违规用户名UID1198296 @ 2024-01-24 21:53:55


@[违规用户名UID1198296](/user/1198296) 大号私信
by pfrig729 @ 2024-01-24 21:57:36


```cpp sort(h+1,h+k+1,cmp1); sort(l+1,l+ll+1,cmp1); ``` and ```cpp sort(l+1,l+k+1,cmp1); sort(h+1,h+ll+1,cmp1); ```
by ZMHjbm @ 2024-01-27 09:10:06


|