[解題報告][ZeroJudge][d550] 物件排序 七月 9, 2010 程式碼, ZeroJudge 本文总阅读量次 下有捏請注意 原始版1234567891011121314151617181920212223242526272829303132333435/*Problem: d550Language: C++Result: AC (375ms, 5327KB) on ZeroJudgeAuthor: m80126colin at 2010-07-09 13:40:13Solution: Straight Forward*/#include <iostream>#include <algorithm>using namespace std;int n,m,s[10000][200],h[10000];bool cmp(int x,int y) { int i; for (i=0;i<m;i++) { if (s[x][i]!=s[y][i]) return s[x][i]<s[y][i]; } return 1;}int main() { int i,j; while (~scanf("%d%d",&n,&m)) { for (i=0;i<n;i++) { h[i]=i; for (j=0;j<m;j++) scanf("%d",&s[i][j]); } sort(h,h+n,cmp); for (i=0;i<n;i++) { for (j=0;j<m;j++) printf("%d ",s[h[i]][j]); printf("\n"); } }} 短碼版123456789101112/*Problem: d550 (short version)Language: C++Result: AC (395ms, 5355KB) on ZeroJudgeAuthor: m80126colin at 2010-07-09 14:39:35Solution: Straight Forward*/#include <iostream>int n,m,s[10001][201],h[10001],i,j,z;bool cmp(int x,int y){for (z=m;z&&s[x][z]==s[y][z];z--) ;return s[x][z]>s[y][z];}int a(){for (i=n,j=--m;i;j?j--:(j=m,h[i]=i--))scanf("%d",&s[i][j]);for (std::sort(h+1,h+n+1,cmp),i=n,j=m;i;j?j--:(i--,j=m,putchar(10)))printf("%d ",s[h[i]][j]);return 1;}int main(){~scanf("%d%d",&n,&m)&&a()&& main();} Newer [解題報告][ZeroJudge][d555] 平面上的極大點 Older 第二波書單release