Share your repls and programming experiences

← Back to all posts
#WEEKLY 20
FlaminHotValdez (690)

If you use C++, you know that you can COMPLETELY ABUSE SET to finish this weekly challenge. Sets are containers, but all of their elements have to be unique, which makes it perfect for this weekly challenge ;)

Comments
hotnewtop
Coder100 (18144)

>:( bad code quality

please fix your code, thanks:

#include <iostream>
#include <set>

int main() {
  int n, m;

  std::cin >> n >> m;

  int arr[n][m];

  std::set<int> set;

  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= m; j++) {
      arr[i-1][j-1] = i * j;
      arr[j-1][i-1] = arr[i-1][j-1];
      set.insert(arr[i-1][j-1]);
    }
  }
  
  std::cout << set.size() << std::endl;
}

Like does this get more evident of bad code quality?

FlaminHotValdez (690)

@Coder100 XD, IK, but I've basically been trained to code quickly for contests, so I cut corners where I can.

Coder100 (18144)

can you use my code pweeaassee @maxyang