Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3320 | 邓小龙 | 长方形排序 | C++ | Accepted | 10 MS | 276 KB | 875 | 2024-05-17 12:24:02 |
# include<iostream> # include<algorithm> using namespace std; struct Rectangle{ int id; int len1; int len2; }; bool cmp(Rectangle a, Rectangle b){ if(a.id==b.id){ if(a.len1==b.len1) return a.len2<b.len2; else return a.len1<b.len1; } else return a.id<b.id; } int main(){ int m; Rectangle rect[1001]; cin>>m; for(int i=0;i<m;i++){ cin>>rect[i].id>>rect[i].len1>>rect[i].len2; if(rect[i].len1<rect[i].len2) swap(rect[i].len1,rect[i].len2); } sort(rect,rect+m,cmp); cout<<rect[0].id<<" "<<rect[0].len1<<" "<<rect[0].len2<<endl; for(int i=1;i<m;i++){ if(rect[i].id==rect[i-1].id&&rect[i].len1==rect[i-1].len1&&rect[i].len2==rect[i-1].len2) continue; cout<<rect[i].id<<" "<<rect[i].len1<<" "<<rect[i].len2<<endl; } return 0; }