I am solving 181B - Number of Triplets. With the constraints being $$$n <= 3000$$$ and my solution supposedly running in $$$O(n^{2})$$$. Am I missing something? 88909110.
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | djm03178 | 152 |
I am solving 181B - Number of Triplets. With the constraints being $$$n <= 3000$$$ and my solution supposedly running in $$$O(n^{2})$$$. Am I missing something? 88909110.
Name |
---|
Map with key of pair<long double, long double> would be slow, though still surprised it TLE's (actually on second thought I'm not, it is like O(n^2lgn) with rlly bad constant factor. Plug in 3000). Don't divide coordinates by 2, just multiply all coordinates by 2, and no need to work with doubles, and try not to use map in the first place (constraints are small). In general, try to avoid doubles, they are slow, and use array when you can.
Since you are using map it's $$$O(n^2 \log n)$$$. Also float arithmetic consumes huge constant factor, that's probably why you are getting TLE.