2 / 2
Feb 22

I was solving the problem NICEDAY - The day of the competitors2
(i know its BIT / segment tree problem it was there in practice BIT) i just thought this approach

I dont know what am i missing maybe i misunderstood the problem whts wrong in my approach

void solve() {
// solution for each test case
int num;
cin >> num;
vector<vector> arr(num,vector(3));
vector<vector> ranks(num);
for (int i = 0; i < num ; i++)
{
for (int j = 0; j < 3 ; j++)
{
cin >> arr[i][j];
ranks[arr[i][j]-1].push_back(i);
}

}
set s;
vector cnt(num,0);
for(int i = 0; i < num; i++){
set t;
int f = 1;
for (int j = 0; j < ranks[i].size(); j++)
{
cnt[ranks[i][j]]++;
t.insert(ranks[i][j]);
if(cnt[ranks[i][j]] == 3){
f = 0;
break;
}
}
if(f){
for(auto &it : t)
s.insert(it);

if(s.size() == num){
break;
}
}
else{
break;
}
}
cout << s.size() << endl;

}

  • created

    Feb 20
  • last reply

    Feb 22
  • 1

    reply

  • 96

    views

  • 2

    users

  • 1

    link

I see you’ve not got AC, so I guess you found the problem.