The HELL?

Правка en3, от Qualified, 2020-07-09 19:59:59

Run this O(n^2) program in CF custom test

#include "bits/stdc++.h"
using namespace std;

long long n;

int main() {
    cin >> n;
    for(long long i = 1; i <= n; i++) {
        for(long long j = 1; j <= n; j++) {
            if((i ^ j) == 0) {
                if(i != j) {
                    cout << "NO!\n";
                    return 0;
                }
            }
        }
    }
    cout << "YES\n";
}

with n = 100000000000

You would expect it to be much longer than 1 second, but it takes

15 ms

screenshot

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Qualified 2020-07-09 19:59:59 0 (published)
en2 Английский Qualified 2020-07-09 19:57:46 9 Tiny change: '00000`\n\nYou woul' -> '00000`\n\n`O(n^2)`\nYou woul' (saved to drafts)
en1 Английский Qualified 2020-07-09 19:56:00 600 Initial revision (published)