QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#596365#9176. Non-Interactive NimLeoGWA 23ms3860kbC++202.1kb2024-09-28 15:37:272024-09-28 15:37:28

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 15:37:28]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:3860kb
  • [2024-09-28 15:37:27]
  • 提交

answer

#include<bits/stdc++.h>
#define ll    long long

template<typename T, typename = void>
struct is_printable : std::false_type {};

template<typename T>
struct is_printable<T, std::void_t<decltype(std::declval<std::ostream&>() << std::declval<T>())>> : std::true_type {};
template <typename T>
void print(const std::pair<T, T>& pair) {
    std::cout << "(" << pair.first << ", " << pair.second << ")";
}

// General print function
template <typename T>
void print(const T& val) {
    std::cout << val;
}

// Print function for std::vector
template <typename T>
void print(const std::vector<T>& vec) {
    std::cout << '[';
    int n = vec.size();
    for (int i = 0; i < n; i++) {
        print(vec[i]);
        if (i < n - 1) {
            std::cout << ",";
        }
    }
    std::cout << ']' << '\n';
}

// Variadic template print function
template<typename T, typename... Args>
void print(const T& t, const Args&... args) {
    print(t);
    std::cout << (is_printable<T>::value ? ' ' : '\0');
    print(args...);
    if (sizeof...(args) == 1 && is_printable<T>::value) std::cout << '\n';

}

void solve(){
    int n;
    std::cin >> n;
    std::vector<int> a(n), tmp;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    bool flag = false;
    std::vector<std::pair<int, int>> ans;
    for (int d = 0; d < 18; d++) {
        tmp.clear();
        for (int i = 0; i < n; i++) {
            if ((a[i] >> d) & 1) {
                tmp.push_back(i);
            }
        }
        if (tmp.size() == 2) {
            flag = true;
            ans.push_back({tmp[0] + 1, 1 << d});
        }
    }
    if (ans.empty()) {
        std::cout << "-1\n";
    }
    else {
        std::cout << ans.size() << std::endl;
        for (auto& [x, y] : ans) {
            std::cout << x << " " << y << "\n";
        }
        if (!flag) std::cout << "-1\n";
    }


    

}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t = 1;
    std::cin >> t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

2
4
4 2 7 1
4
1 1 1 1

output:

3
3 1
2 2
1 4
-1

result:

ok OK 1 yes 1 no (2 test cases)

Test #2:

score: 0
Accepted
time: 23ms
memory: 3624kb

input:

50000
2
3 3
2
2 2
2
3 3
2
2 2
2
3 3
2
3 3
2
1 1
2
1 1
2
1 1
2
2 2
2
2 2
2
3 3
2
2 2
2
1 1
2
3 3
2
1 1
2
1 1
2
1 1
2
3 3
2
1 1
2
1 1
2
3 3
2
2 2
2
3 3
2
3 3
2
2 2
2
1 1
2
3 3
2
2 2
2
2 2
2
3 3
2
3 3
2
1 1
2
1 1
2
1 1
2
3 3
2
3 3
2
1 1
2
1 1
2
3 3
2
2 2
2
2 2
2
2 2
2
1 1
2
1 1
2
2 2
2
2 2
2
1 1
2
3 3
...

output:

2
1 1
1 2
1
1 2
2
1 1
1 2
1
1 2
2
1 1
1 2
2
1 1
1 2
1
1 1
1
1 1
1
1 1
1
1 2
1
1 2
2
1 1
1 2
1
1 2
1
1 1
2
1 1
1 2
1
1 1
1
1 1
1
1 1
2
1 1
1 2
1
1 1
1
1 1
2
1 1
1 2
1
1 2
2
1 1
1 2
2
1 1
1 2
1
1 2
1
1 1
2
1 1
1 2
1
1 2
1
1 2
2
1 1
1 2
2
1 1
1 2
1
1 1
1
1 1
1
1 1
2
1 1
1 2
2
1 1
1 2
1
1 1
1
1 1
2
1 1
...

result:

ok OK 50000 yes 0 no (50000 test cases)

Test #3:

score: -100
Wrong Answer
time: 6ms
memory: 3860kb

input:

50000
2
89846347117873058 89846347117873058
2
416235892302498917 416235892302498917
2
332154513003612985 332154513003612985
2
43960216631774959 43960216631774959
2
353215896487285554 353215896487285554
2
38296945667390613 38296945667390613
2
209150071115726640 209150071115726640
2
48610805835417777 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

wrong answer judge has answer but participant doesn't (test case 1)