注意题给条件:
第二个和第三个数值大的表示长,数值小的表示宽,相等
说明这是一个正方形(数据约定长宽与编号都小于10000)
此后注意去重就好啦
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <map> #define ll long long using namespace std ; typedef struct{ int id ; int length ; int wide ; }meassage ; bool cmp( meassage a , meassage b ){ if ( a.id == b.id ){ if ( a.length == b.length ){ return a.wide < b.wide ; } return a.length < b.length ; } return a.id < b.id ; } bool check( meassage a , meassage b ){ if ( a.id == b.id && a.length == b.length && a.wide == b.wide ){ return true ; } return false ; } int main(){ int t ; cin >> t ; while ( t -- ){ int n ; cin >> n ; meassage mea[n+10] ; for ( int i = 0 ; i < n ; i ++ ){ cin >> mea[i].id >> mea[i].length >> mea[i].wide ; if ( mea[i].wide > mea[i].length ){ swap(mea[i].wide , mea[i].length) ; } } sort( mea , mea + n , cmp ) ; printf("%d %d %d\n" , mea[0].id , mea[0].length , mea[0].wide) ; for ( int i = 1 ; i < n ; i ++ ){ if ( !check(mea[i] , mea[i-1]) ){ printf("%d %d %d\n" , mea[i].id , mea[i].length , mea[i].wide) ; } } } return 0 ; }
原文地址:https://www.cnblogs.com/Cantredo/p/9716236.html
时间: 2024-11-13 04:38:16