111 条题解
- 
  1伊人 LV 8 @ 2017-10-31 16:57:53 模拟一下就好(。◕ˇ∀ˇ◕) #include<iostream> #include<cstring> #include<algorithm> using namespace std; int csh[1100],csl[1100],ansh[1100],ansl[1100]; bool bj1[1100],bj2[1100]; struct student{ int x; int y; }a[5000]; int main() { memset(bj1,1,sizeof(bj1)); memset(bj2,1,sizeof(bj2)); memset(csh,0,sizeof(csh)); memset(csl,0,sizeof(csl)); int m,n,k,l,d,p=1; cin>>m>>n>>k>>l>>d; for(int i=1;i<=d;++i) { cin>>a[p].x>>a[p].y>>a[p+1].x>>a[p+1].y; if(a[p].x>a[p+1].x) csh[a[p+1].x]++; else if(a[p].x<a[p+1].x) csh[a[p].x]++; else { if(a[p].y>a[p+1].y) csl[a[p+1].y]++; else if(a[p].y<a[p+1].y) csl[a[p].y]++; } p+=2; } int hh=k,ll=l,xb,first1,first2,js1=0,js2=0; while(hh!=0) { first1=0; js1++; for(int i=1;i<=1000;++i) { if(csh[i]>first1&&bj1[i]!=0) { first1=csh[i]; xb=i; } } ansh[js1]=xb; bj1[xb]=0; hh--; } while(ll!=0) { first2=0; js2++; for(int i=1;i<=1000;++i) { if(csl[i]>first2&&bj2[i]!=0) { first2=csl[i]; xb=i; } } ansl[js2]=xb; bj2[xb]=0; ll--; } sort(ansh+1,ansh+js1+1); sort(ansl+1,ansl+js2+1); for(int i=1;i<=k;++i) cout<<ansh[i]<<" "; cout<<endl; for(int j=1;j<=l;++j) cout<<ansl[j]<<" "; return 0; }
- 
  1@ 2017-09-21 15:20:12四次快排不解释 #include<iostream> #include<algorithm> using namespace std; struct node1 { int num,sh; }heng[1010]; struct node2 { int num,sh; }shu[1010]; int comp1(const node1&x,const node1&y) { if(x.sh>y.sh) return 1; return 0; } int comp2(const node2&x,const node2&y) { if(x.sh>y.sh) return 1; return 0; } int comp3(const node1&x,const node1&y) { if(x.num<y.num) return 1; return 0; } int comp4(const node2&x,const node2&y) { if(x.num<y.num) return 1; return 0; } int main() { int m,n,k,l,d,x1,x2,y1,y2,i; cin>>m>>n>>k>>l>>d; for(i=1;i<=1002;i++) { shu[i].num=i; shu[i].sh=0; } for(i=1;i<=1002;i++) { heng[i].num=i; heng[i].sh=0; } for(i=1;i<=d;i++) { cin>>x1>>y1>>x2>>y2; if(x1==x2) { heng[min(y1,y2)].sh++; } else { shu[min(x1,x2)].sh++; } } sort(heng+1,heng+n+1,comp1); sort(shu+1,shu+m+1,comp2); sort(heng+1,heng+l+1,comp3); sort(shu+1,shu+k+1,comp4); for(i=1;i<=k;i++) { if(i!=k) cout<<shu[i].num<<" "; else cout<<shu[i].num; } cout<<endl; for(i=1;i<=l;i++) { if(i!=l) cout<<heng[i].num<<" "; else cout<<heng[i].num; } return 0; }
- 
  1@ 2017-04-08 10:11:12#include <iostream> 
 #include <iomanip>
 #include <cstdlib>
 #include <cmath>
 #include <string>
 #include <cstdio>
 #include <algorithm>
 using namespace std;
 struct s
 {
 int num;
 int id;
 bool operator<(const s &a) const
 {
 return num>a.num;
 }
 }xk[1005],yk[1005];
 int m,n,k,l,d;
 int x,y,p,q,i,w;
 int an1[1005],an2[1005];
 int main()
 {
 scanf("%d%d%d%d%d",&m,&n,&k,&l,&d);
 for(i=1;i<=d;i++)
 {
 scanf("%d%d%d%d",&x,&y,&p,&q);
 if(x==p)
 {
 w=min(y,q);
 yk[w].num++;
 yk[w].id=w;
 }
 else
 {
 w=min(x,p);
 xk[w].num++;
 xk[w].id=w;
 }
 }
 sort(xk+1,xk+m+1);
 sort(yk+1,yk+n+1);
 for(i=1;i<=k;i++) an1[i]=xk[i].id;
 for(i=1;i<=l;i++) an2[i]=yk[i].id;
 sort(an1+1,an1+k+1);
 sort(an2+1,an2+l+1);
 for(i=1;i<=k;i++) printf("%d ",an1[i]);printf("\n");
 for(i=1;i<=l;i++) printf("%d ",an2[i]);printf("\n");
 system("pause");
 return 0;
 }
- 
  0@ 2017-11-05 16:58:29//统计两个相同坐标中不同的部分的最小值来计算每条路径的价值,并通过它的价值解出优先分开的路径,从而得出能够分开的最多桌数。 
 var i1,i2,j1,j2,i,j,m,n,k,l,d:longint;
 a,b:array[0..1001,1..2]of longint;
 begin
 readln(m,n,k,l,d);
 for i:=1 to m do a[i,2]:=i;
 for i:=1 to n do b[i,2]:=i;
 for i:=1 to d do
 begin
 readln(i1,i2,j1,j2);
 if i1=j1 then
 begin
 if i2<j2 then inc(a[i2,1])
 else inc(a[j2,1]);
 end
 else if i1<j1 then inc(b[i1,1])
 else inc(b[j1,1]);
 end;
 for i:=1 to n-1 do
 for j:=i+1 to n do
 if b[i,1]<b[j,1]then
 begin
 b[0]:=b[i];
 b[i]:=b[j];
 b[j]:=b[0];
 end;
 for i:=1 to k-1 do
 for j:=i+1 to k do
 if b[i,2]>b[j,2]then
 begin
 b[0]:=b[i];
 b[i]:=b[j];
 b[j]:=b[0];
 end;
 for i:=1 to k do write(b[i,2],' ');
 writeln;
 for i:=1 to m-1 do
 for j:=i+1 to m do
 if a[i,1]<a[j,1]then
 begin
 a[0]:=a[i];
 a[i]:=a[j];
 a[j]:=a[0];
 end;
 for i:=1 to l-1 do
 for j:=i+1 to l do
 if a[i,2]>a[j,2]then
 begin
 a[0]:=a[i];
 a[i]:=a[j];
 a[j]:=a[0];
 end;
 for i:=1 to l do write(a[i,2],' ');
 end.
- 
  0@ 2017-08-03 18:48:21Var 
 i,j,k,n,m,d,l2,num,x1,x2,y1,y2,t:longint;
 h,l,h1,l1:array[1..10000]of longint;
 a,b:array[1..10000,1..2]of longint;Function min(x,y:longint):longint; 
 Begin
 if x<y then
 exit(x)
 else
 exit(y);
 End;Begin 
 readln(m,n,k,l2,d);
 for i:=1 to d do
 begin
 readln(x1,y1,x2,y2);
 if x1=x2 then
 begin
 num:=min(y1,y2);
 inc(l[num]);
 end
 else
 if y1=y2 then
 begin
 num:=min(x1,x2);
 inc(h[num]);
 end;
 end;
 for i:=1 to m do
 h1[i]:=i;
 for i:=1 to n do
 l1[i]:=i;
 for i:=1 to m-1 do
 for j:=i+1 to m do
 if h[i]<h[j] then
 begin
 t:=h[i]; h[i]:=h[j]; h[j]:=t;
 t:=h1[i]; h1[i]:=h1[j]; h1[j]:=t;
 end;
 for i:=1 to n-1 do
 for j:=i+1 to n do
 if l[i]<l[j] then
 begin
 t:=l[i]; l[i]:=l[j]; l[j]:=t;
 t:=l1[i]; l1[i]:=l1[j]; l1[j]:=t;
 end;
 for i:=1 to k-1 do
 for j:=i+1 to k do
 if h1[i]>h1[j] then
 begin
 t:=h1[i]; h1[i]:=h1[j]; h1[j]:=t;
 end;
 for i:=1 to l2-1 do
 for j:=i+1 to l2 do
 if l1[i]>l1[j] then
 begin
 t:=l1[i]; l1[i]:=l1[j]; l1[j]:=t;
 end;
 for i:=1 to k-1 do
 write(h1[i],' ');
 writeln(h1[k]);
 for i:=1 to l2-1 do
 write(l1[i],' ');
 writeln(l1[l2]);
 readln;
 End.
 这道题我真的无语,,这么简单的一道题,我居然用了8次。。原因居然是我没理解清题目。原来后面的结果要按从小到大排序,而且不用看每条通道可以隔绝多少对来排。。。
- 
  0@ 2017-03-09 09:25:00利用STL进行排序,结合贪心思想即可 #include<iostream> 
 #include<algorithm>
 #include<cstdio>
 using namespace std;
 int i,j,m,n,k,l,d,x,y,p,q,tem;struct data 
 {
 int oral,sum;
 }
 lin[1001],row[1001];int readd() 
 {
 int ou=0;
 char ch=getchar();
 while(ch>'9'||ch<'0')
 ch=getchar();
 while(ch<='9'&&ch>='0')
 {
 ou*=10;
 ou+=ch-'0';
 ch=getchar();
 }return ou; 
 }int cmp(data xx,data xy) 
 {
 if(xx.sum>xy.sum) return 1;
 return 0;
 }int cmp1(data xx,data xy) 
 {
 if(xx.oral<xy.oral) return 1;
 return 0;
 }int main() 
 {
 //freopen("1.txt","w",stdout);
 m=readd();n=readd();k=readd();l=readd();d=readd();
 for(i=1;i<=m;i++)
 lin[i].oral=i;
 for(i=1;i<=n;i++)
 row[i].oral=i;
 for(i=1;i<=d;i++)
 {
 x=readd();y=readd();p=readd();q=readd();
 if(x==p)
 lin[min(y,q)].sum++;
 else
 row[min(x,p)].sum++;
 }
 sort(lin+1,lin+n+1,cmp);
 sort(row+1,row+n+1,cmp);
 sort(lin+1,lin+l+1,cmp1);
 sort(row+1,row+k+1,cmp1);
 if(k)
 {
 cout<<row[1].oral;
 for(i=2;i<=k;i++)
 cout<<" "<<row[i].oral;}
 if(l)
 {
 cout<<endl;
 cout<<lin[1].oral;
 for(i=2;i<=l;i++)
 cout<<" "<<lin[i].oral;}} 
- 
  0@ 2016-12-24 16:21:05#include<cstdio> 
 #include<iostream>
 #include<algorithm>
 #define maxa 1010
 using namespace std;
 struct Node
 {
 int id;
 int key;
 }r[maxa],c[maxa];
 bool comp(Node a,Node b)
 {
 return a.key>b.key;
 }
 int main()
 {
 int m,n,k,l,d;
 int x,y,p,q,t,i;
 int a[maxa],b[maxa];
 scanf("%d%d%d%d%d",&m,&n,&k,&l,&d);
 while(d--)
 {
 scanf("%d%d%d%d",&x,&y,&p,&q);
 if(x==p&&y!=q)
 {
 t = min(y,q);
 c[t].id = t;
 c[t].key++;
 }
 else if(y==q)
 {
 t = min(x,p);
 r[t].id =t;
 r[t].key++;
 }
 }
 sort(r,r+m+1,comp);
 sort(c,c+n+1,comp);
 for(i=0;i<k;++i)
 a[i] = r[i].id;
 for(i=0;i<l;++i)
 b[i] = c[i].id;
 sort(a,a+k);
 sort(b,b+l);
 for(i=0;i<k;++i)
 printf("%d ",a[i]);
 printf("\n");
 for(i=0;i<l;++i)
 printf("%d ",b[i]);
 return 0;
 }
- 
  0@ 2016-10-05 14:35:12STL大法好! 评测结果 
 编译成功测试数据 #0: Accepted, time = 0 ms, mem = 596 KiB, score = 10 
 测试数据 #1: Accepted, time = 0 ms, mem = 596 KiB, score = 10
 测试数据 #2: Accepted, time = 0 ms, mem = 596 KiB, score = 10
 测试数据 #3: Accepted, time = 0 ms, mem = 592 KiB, score = 10
 测试数据 #4: Accepted, time = 0 ms, mem = 596 KiB, score = 10
 测试数据 #5: Accepted, time = 0 ms, mem = 596 KiB, score = 10
 测试数据 #6: Accepted, time = 0 ms, mem = 596 KiB, score = 10
 测试数据 #7: Accepted, time = 0 ms, mem = 600 KiB, score = 10
 测试数据 #8: Accepted, time = 0 ms, mem = 600 KiB, score = 10
 测试数据 #9: Accepted, time = 0 ms, mem = 600 KiB, score = 10
 Accepted, time = 0 ms, mem = 600 KiB, score = 100代码 
 c++
 #include<cstdio>
 #include<algorithm>
 #include<vector>
 #include<queue>
 using namespace std;
 struct stc{
 int x1,y1,x2,y2;
 }a[2002];
 struct stc2{
 int num,p;
 stc2(int num,int p):num(num),p(p){
 }
 bool operator <(stc2 rdgs)const{
 return p<rdgs.p;
 }
 };
 vector<int>v;
 priority_queue<stc2> q;
 #define min(a,b) ((a)>(b)?(b):(a))
 int Lie[1002]={0},Hang[1002]={0};
 int main(int noip2008,char** XXXXXXXXXXX){
 int n,m,k,l,d;
 scanf("%d%d%d%d%d",&n,&m,&k,&l,&d);
 for(int i=1;i<=d;i++)
 scanf("%d%d%d%d",&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2);
 for(int i=1;i<=d;i++){
 if(a[i].x1==a[i].x2)
 Lie[min(a[i].y1,a[i].y2)]++;else
 Hang[min(a[i].x1,a[i].x2)]++;
 }
 for(int i=1;i<=n;i++)
 q.push(stc2(i,Hang[i]));
 for(int i=1;i<=k;i++)
 v.push_back(q.top().num),q.pop();
 sort(v.begin(),v.end());
 for(vector<int>::iterator i=v.begin();i!=v.end();i++)
 printf("%d ",*i);
 putchar('\n');
 q=priority_queue<stc2>();
 v.clear();
 for(int i=1;i<=m;i++)
 q.push(stc2(i,Lie[i]));
 for(int i=1;i<=l;i++)
 v.push_back(q.top().num),q.pop();
 sort(v.begin(),v.end());
 for(vector<int>::iterator i=v.begin();i!=v.end();i++)
 printf("%d ",*i);
 putchar('\n');
 return 0;
 }
- 
  0@ 2016-09-02 22:04:32#include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<cstring> using namespace std; const int maxn = 2000; const int INF = 1000000000; struct Node{ int val, num; bool operator < (const Node& rhs) const { return val > rhs.val; } }r[maxn], c[maxn]; int n, m, k, l, d; vector<int> rans; vector<int> cans; int main(){ cin >> n >> m >> k >> l >> d; int x1, y1, x2, y2; for (int i = 0; i < max(n, m); i++) { r[i].num = c[i].num = i; } for (int i = 0; i < d; i++) { scanf("%d%d%d%d", &x1, &y1, &x2, &y2); x1--; x2--; y1--; y2--; if (x1 == x2) { c[min(y1, y2)].val++; } else { r[min(x1, x2)].val++; } } sort(r, r+n); sort(c, c+m); for (int i = 0; i < k; i++) rans.push_back(r[i].num); for (int i = 0; i < l; i++) cans.push_back(c[i].num); sort(rans.begin(), rans.end()); sort(cans.begin(), cans.end()); for (int i = 0; i < rans.size(); i++) printf("%d ", rans[i]+1); cout << "\n"; for (int i = 0; i < cans.size(); i++) printf("%d ", cans[i]+1); return 0; }
- 
  0@ 2016-08-19 19:48:41uses math; 
 type arr=array[1..2000]of longint;
 var
 a:array[1..2020,1..4]of longint;
 f1,f2,f3,f4:array[1..2000]of longint;
 m,n,k,l,d,i,j,tmp,maxer:longint;
 fa,fb:array[1..2000]of boolean;
 procedure xp(var a:arr;b:longint);
 var
 i,j,tmp:longint;
 begin
 for i:=1 to b-1 do
 for j:=i+1 to b do
 begin
 if a[i]>a[j] then
 begin
 tmp:=a[i];
 a[i]:=a[j];
 a[j]:=tmp;
 end;
 end;
 end;
 begin
 readln(m,n,k,l,d);
 for i:=1 to d do
 for j:=1 to 4 do
 read(a[i,j]);
 fillchar(f1,sizeof(f1),0);
 fillchar(f2,sizeof(f2),0);
 for i:=1 to m do
 for j:=1 to d do
 if (min(a[j,1],a[j,3])=i) and (max(a[j,1],a[j,3])=i+1) then inc(f1[i]);
 for i:=1 to n do
 for j:=1 to d do
 if (min(a[j,2],a[j,4])=i) and (max(a[j,2],a[j,4])=i+1) then inc(f2[i]);
 fillchar(fa,sizeof(fa),true);
 fillchar(fb,sizeof(fb),true);
 for i:=1 to k do
 begin
 maxer:=1;
 while fa[maxer]=false do inc(maxer);
 for j:=1 to m do
 if (f1[j]>f1[maxer]) and (fa[j]=true) then maxer:=j;
 f3[i]:=maxer;
 fa[maxer]:=false;
 end;
 maxer:=1;
 for i:=1 to l do
 begin
 maxer:=1;
 while fb[maxer]=false do inc(maxer);
 for j:=1 to n do
 if (f2[j]>f2[maxer]) and (fb[j]=true) then maxer:=j;
 f4[i]:=maxer;
 fb[maxer]:=false;
 end;
 xp(f3,k);
 xp(f4,l);
 for i:=1 to k-1 do
 write(f3[i],' ');
 writeln(f3[k]);
 for i:=1 to l-1 do
 write(f4[i],' ');
 write(f4[l]);
 end.
- 
  0@ 2015-08-30 15:22:29
- 
  0@ 2015-08-26 19:40:31感觉有点难,不过还是过了,呼呼,(~ o ~)~zZ…… 
 #include<iostream>
 #include<cstdio>
 #include<algorithm>
 using namespace std;
 struct zong{
 int sum,num;
 }y[2001];
 struct heng{
 int sum,num;
 }x[2001];
 int dog(const zong&a,const zong&b)
 {
 return a.sum>b.sum;
 }
 int cat(const heng&a,const heng&b)
 {
 return a.sum>b.sum;
 }
 int tiger(const zong&a,const zong&b)
 {
 return a.num<b.num;
 }
 int sheep(const heng&a,const heng&b)
 {
 return a.num<b.num;
 }
 int main()
 {
 int m,n,k,l,d,x1,y1,x2,y2,i;
 scanf("%d%d%d%d%d",&m,&n,&k,&l,&d);
 for(i=1;i<=m;i++){
 x[i].num=i;
 }
 for(i=1;i<=n;i++){
 y[i].num=i;
 }
 for(i=1;i<=d;i++){
 scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
 if(x1==x2){
 y[y1<y2?y1:y2].sum++;
 }
 else{
 x[x1<x2?x1:x2].sum++;
 }
 }
 sort(x+1,x+m+1,cat);
 sort(y+1,y+n+1,dog);
 sort(x+1,x+k+1,sheep);
 sort(y+1,y+l+1,tiger);
 for(i=1;i<=k;i++){
 printf("%d ",x[i].num);
 }
 printf("\n");
 for(i=1;i<=l;i++){
 printf("%d ",y[i].num);
 }
 return 0;
 }
- 
  0@ 2015-08-10 10:05:29编译成功 Free Pascal Compiler version 2.6.4 [2014/03/06] for i386 
 Copyright (c) 1993-2014 by Florian Klaempfl and others
 Target OS: Win32 for i386
 Compiling foo.pas
 foo.pas(27,33) Warning: Variable "a" does not seem to be initialized
 foo.pas(28,33) Warning: Variable "b" does not seem to be initialized
 foo.pas(35,10) Warning: Variable "u" does not seem to be initialized
 Linking foo.exe
 52 lines compiled, 0.1 sec , 29232 bytes code, 1628 bytes data
 3 warning(s) issued
 测试数据 #0: Accepted, time = 0 ms, mem = 772 KiB, score = 10
 测试数据 #1: Accepted, time = 2 ms, mem = 772 KiB, score = 10
 测试数据 #2: Accepted, time = 0 ms, mem = 776 KiB, score = 10
 测试数据 #3: Accepted, time = 1 ms, mem = 776 KiB, score = 10
 测试数据 #4: Accepted, time = 6 ms, mem = 772 KiB, score = 10
 测试数据 #5: Accepted, time = 0 ms, mem = 772 KiB, score = 10
 测试数据 #6: Accepted, time = 3 ms, mem = 772 KiB, score = 10
 测试数据 #7: Accepted, time = 2 ms, mem = 776 KiB, score = 10
 测试数据 #8: Accepted, time = 0 ms, mem = 776 KiB, score = 10
 测试数据 #9: Accepted, time = 2 ms, mem = 772 KiB, score = 10
 Accepted, time = 16 ms, mem = 776 KiB, score = 100
 代码
 var
 m,n,k,l,d,q,w,e,r,i,j,max,u,f:longint;
 a,b,uu:array[1..1000]of longint;
 procedure sw(var i,j:longint);
 var p:longint;
 begin
 p:=uu[i];uu[i]:=uu[j];uu[j]:=p;
 inc(i);dec(j);
 end;
 procedure qsort(i,j:longint);
 var l,r,mid:longint;
 begin
 l:=i;r:=j;mid:=uu[(l+r) div 2];
 repeat
 while uu[i]<mid do inc(i);
 while uu[j]>mid do dec(j);
 if i<=j then sw(i,j);
 until i>j;
 if i<r then qsort(i,r);
 if l<j then qsort(l,j);
 end;
 begin
 readln(m,n,k,l,d);
 for i:=1 to d do
 begin
 readln(q,w,e,r);
 if q=e then if w<r then inc(a[w]) else inc(a[r]);
 if w=r then if q<e then inc(b[q]) else inc(b[e]);
 end;
 for i:=1 to k do
 begin
 max:=0;
 for j:=1 to m-1 do
 if b[j]>max then begin max:=b[j];f:=j; end;
 inc(u);uu[u]:=f;b[f]:=0;
 end;
 qsort(1,u);
 for i:=1 to u-1 do write(uu[i],' ');
 writeln(uu[u]);u:=0; for i:=1 to l do 
 begin max:=0;
 for j:=1 to n-1 do
 if a[j]>max then begin max:=a[j];f:=j; end;
 inc(u);uu[u]:=f;a[f]:=0;
 end;
 qsort(1,u);
 for i:=1 to u-1 do write(uu[i],' ');
 writeln(uu[u]);
 end.
- 
  0@ 2015-06-06 20:22:27录入信息的时候即时处理,处理完之后排序选出最优解,再之后在排序按顺序输出 
 --完毕--#include<cstdio> 
 #include<cstring>
 #include<iostream>
 #include<algorithm>
 using namespace std;
 struct Node
 {
 int sum,num;
 }x[1005],y[1005];bool rule1(Node a,Node b) 
 {
 return a.sum>b.sum;
 }bool rule2(Node a,Node b) 
 {
 return a.num<b.num;
 }int main() 
 {
 int m,n,k,l,d;
 cin >> m >> n >> k >> l >> d;
 for(int i=0;i<=m;i++)
 {
 x[i].num=i;
 }
 for(int i=0;i<=n;i++)
 {
 y[i].num=i;
 }
 for (int i=0,xi,yi,pi,qi;i<d;i++)
 {
 scanf("%d %d %d %d",&xi,&yi,&pi,&qi);
 if(xi==pi)
 {
 y[yi<qi?yi:qi].sum++;
 }
 else if(yi==qi)
 {
 x[xi<pi?xi:pi].sum++;
 }
 }
 sort(x,x+m,rule1);
 sort(y,y+n,rule1);
 sort(x,x+k,rule2);
 sort(y,y+l,rule2);
 for(int i=0;i<k;i++)
 {
 printf("%d ",x[i].num);
 }
 cout << endl;
 for(int i=0;i<l;i++)
 {
 printf("%d ",y[i].num);
 }
 return 0;
 }
- 
  0@ 2015-02-06 13:32:42c++std 秒杀c++ code#include<cstdio> 
 #include<algorithm>
 #include<vector>
 using namespace std;
 int m,n,k,l,d,ak[1002]={0},al[1002]={0};
 vector<int> ansk,ansl;
 inline void setk()
 {
 int *p=max_element(ak,ak+1002);
 ansk.push_back(int(p-ak));
 *p=0;
 }
 inline void setl()
 {
 int *p=max_element(al,al+1002);
 ansl.push_back(int(p-al));
 *p=0;
 }
 int main()
 {
 scanf("%d%d%d%d%d",&m,&n,&k,&l,&d);
 for (int i=0;i!=d;++i)
 {
 int ta,tb,tc,td;
 scanf("%d%d%d%d",&ta,&tb,&tc,&td);
 ta==tc?++al[min(tb,td)]:++ak[min(ta,tc)];
 }
 for (int i=0;i!=k;++i) setk();
 for (int j=0;j!=l;++j) setl();
 sort(ansk.begin(),ansk.end());
 sort(ansl.begin(),ansl.end());
 for (int i=0;i!=k;++i) printf("%d ",ansk[i]);
 printf("\n");
 for (int i=0;i!=l;++i) printf("%d ",ansl[i]);
 }
- 
  0@ 2015-01-16 20:05:33TM的太坑了,注意输出还要排序 
- 
  0@ 2014-11-06 23:28:37type 
 arr=array[1..1000] of longint;
 var
 tdh,tdl,mh,ml:arr;
 maxh:longint;
 maxl:longint;
 i,j,m,n,k,l,x,y,p,q,d:longint;
 function findmax(a:arr):longint;
 var
 i:integer;
 begin
 findmax:=1;
 for i:=2 to 1000 do
 if a[findmax]<a[i] then findmax:=i;
 end;
 begin
 fillchar(tdh,sizeof(tdh),0);
 fillchar(tdl,sizeof(tdl),0);
 read(m,n,k,l,d);
 for i:=1 to d do
 begin
 read(x,y,p,q);
 if x=p then tdl[(y+q) div 2]:=tdl[(y+q) div 2]+1
 else tdh[(x+p) div 2]:=tdh[(x+p) div 2]+1;
 end;
 for i:=1 to k do
 begin
 maxh:=findmax(tdh);
 tdh[maxh]:=0;
 mh[maxh]:=1;
 end;
 for i:=1 to l do
 begin
 maxl:=findmax(tdl);
 tdl[maxl]:=0;
 ml[maxl]:=1;
 end;
 j:=1;
 for i:=1 to m do
 begin
 if (mh[i]=1) and (j=k) then
 begin
 write(i);
 break;
 end;
 if (mh[i]=1) and (j<k) then
 begin
 j:=j+1;
 write(i,' ');
 end;
 end;
 writeln;
 j:=1;
 for i:=1 to n do
 begin
 if (ml[i]=1) and (j=l) then
 begin
 write(i);
 break;
 end;
 if (ml[i]=1) and (j<l) then
 begin
 j:=j+1;
 write(i,' ');
 end;
 end;
 end.
- 
  0@ 2013-12-26 21:34:27#include <stdio.h> 
 #include <iostream>
 #include <stdlib.h>
 #include <string.h>
 using namespace std;
 struct seat{
 int num;
 int sum;
 };
 int cmp (const void *a,const void *b)
 { struct seat *c=(seat *)a;
 struct seat *d=(seat *)b;
 return c->sum<d->sum? 1:-1;
 }
 int main ()
 { seat sa[1001],sb[1001];
 int m,n,k,l,d,i,t,a[1001],b[1001],x,y,p,q;
 memset(a,0,sizeof (a));
 memset(b,0,sizeof (b));
 cin>>m>>n>>k>>l>>d;
 for (i=0;i<d;i++)
 {cin>>x>>y>>p>>q;
 if (x==p)
 {t=y>q? q:y;
 a[t]++;
 }
 else
 {t=x>p? p:x;
 b[t]++;
 }
 }
 for (i=1;i<=m;i++)
 {sa[i-1].num=i;
 sa[i-1].sum=a[i];
 }
 for (i=1;i<=n;i++)
 {sb[i-1].num=i;
 sb[i-1].sum=b[i];
 }
 qsort (sa,m-1,sizeof (sa[0]),cmp);
 qsort (sb,n-1,sizeof (sb[0]),cmp);
 memset (a,0,sizeof (a));
 for (i=0;i<k;i++)
 a[sb[i].num]++;
 for (i=0;i<n;i++)
 if (a[i])
 cout<<i<<" ";
 cout<<endl;
 memset (a,0,sizeof (a));
 for (i=0;i<l;i++)
 a[sa[i].num]++;
 for (i=0;i<m;i++)
 if (a[i])
 cout<<i<<" ";
 return 0;
 }
- 
  0@ 2013-11-04 13:21:20测试数据 #0: Accepted, time = 15 ms, mem = 464 KiB, score = 10 测试数据 #1: Accepted, time = 0 ms, mem = 468 KiB, score = 10 测试数据 #2: Accepted, time = 0 ms, mem = 468 KiB, score = 10 测试数据 #3: Accepted, time = 0 ms, mem = 464 KiB, score = 10 测试数据 #4: Accepted, time = 3 ms, mem = 468 KiB, score = 10 测试数据 #5: Accepted, time = 0 ms, mem = 468 KiB, score = 10 测试数据 #6: Accepted, time = 0 ms, mem = 472 KiB, score = 10 测试数据 #7: Accepted, time = 0 ms, mem = 480 KiB, score = 10 测试数据 #8: Accepted, time = 15 ms, mem = 476 KiB, score = 10 测试数据 #9: Accepted, time = 0 ms, mem = 480 KiB, score = 10 Accepted, time = 33 ms, mem = 480 KiB, score = 100 感觉又有信心了,,一次AC,,爽啊 
 #include<cstdio>
 #include<cstdlib>
 #include<algorithm>
 using namespace std;
 int cmp1(int a[2],int b[2]){ return a[0]>b[0];}
 int cmp2(int a[2],int b[2]){ return a[1]<b[1];}
 int main(){
 int a,b,c,d,m,n,i,j,k;
 scanf("%d %d %d %d %d",&m,&n,&i,&j,&k);
 int **h=new int *[m+1];
 int **l=new int *[n+1];
 for(int q=1;q<=m;q++) h[q]=new int [2],h[q][0]=0,h[q][1]=q;
 for(int q=1;q<=n;q++) l[q]=new int [2],l[q][0]=0,l[q][1]=q;
 for(int q=1;q<=k;q++){
 scanf("%d %d %d %d",&a,&b,&c,&d);
 if(a==c) l[b<d?b:d][0]++;
 else h[a<c?a:c][0]++;
 }
 sort(h+1,h+m+1,cmp1);
 sort(h+1,h+i+1,cmp2);
 sort(l+1,l+n+1,cmp1);
 sort(l+1,l+j+1,cmp2);
 for(int q=1;q<=i;q++)
 printf("%d ",h[q][1]);
 printf("\n");
 for(int q=1;q<=j;q++)
 printf("%d ",l[q][1]);
 return 0;
 }
- 
  0@ 2013-10-22 19:30:46看清输出格式!