版权声明:本人ZZU在校学生,文章均为个人心得,有不足之处请不吝赐教! https://blog.csdn.net/whl_program/article/details/82699604
靠猜答案AC了。。。。。就不放答案了
当时暴力就AC了,其实这道题可以先按照a, b, c优先级排序,然后进行遍历,当前节点和左后一个节点比较,如果小于最后一个节点,直接res++,时间复杂度可以将为O(nlog2n)
以下是暴力代码。。
#include<bits/stdc++.h>
using namespace std;
struct node{
int a;
int b;
int c;
};
int main(){
vector<node> arr;
int count = 0;
int a = 0;
int b = 0;
int c = 0;
int res = 0;
cin >> count;
for (int i = 0; i < count; ++i){
cin >> a >> b >> c;
node temp;
temp.a = a;
temp.b = b;
temp.c = c;
arr.push_back(temp);
}
for (int i = 0; i < count; ++i){
for (int j = 0; j < count; ++j){
if (i == j)
continue;
if (arr[j].a > arr[i].a && arr[j].b > arr[i].b && arr[j].c > arr[i].c){
++res;
break;
}
}
}
cout << res << endl;
return 0;
}