QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#939665#4929. Longest Unfriendly Subsequencejustin2718280 1219ms4224kbC++20716b2025-03-17 14:48:562025-03-17 14:49:09

Judging History

This is the latest submission verdict.

  • [2025-03-17 14:49:09]
  • Judged
  • Verdict: 0
  • Time: 1219ms
  • Memory: 4224kb
  • [2025-03-17 14:48:56]
  • Submitted

answer

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

int main() {
    int t;
    cin >> t;
    for (int qwerty = 0; qwerty < t; qwerty++) {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for (int k = 0; k < 1<<n; k++) {
            vector<int> v;
            bool valid = true;
            for (int i = 0; i < n; i++) if (k & 1<<i) v.push_back(a[i]);
            if (v.size() >= 3) for (int i = 2; i < v.size(); i++) {
                if (v[i] == v[i-1] || v[i] == v[i-2]) valid = false;
            }
            if (valid) ans = max(ans, (int)v.size());
        }
        cout << ans << "\n";
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 55ms
memory: 4224kb

input:

1
200000
259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 259021863 2...

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 1ms
memory: 3584kb

input:

3
5
1 2 1 2 1
7
1 2 3 2 1 2 3
8
1 10 10 1 1 100 100 1

output:

3
6
4

result:

wrong answer 1st lines differ - expected: '2', found: '3'

Subtask #3:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 1219ms
memory: 3584kb

input:

1
500
537076440 691668159 871942500 537076440 537076440 691668159 871942500 871942500 537076440 691668159 871942500 537076440 691668159 871942500 537076440 691668159 871942500 537076440 691668159 871942500 537076440 691668159 871942500 871942500 537076440 691668159 871942500 537076440 537076440 6916...

output:

0

result:

wrong answer 1st lines differ - expected: '361', found: '0'

Subtask #4:

score: 0
Wrong Answer

Test #79:

score: 0
Wrong Answer
time: 20ms
memory: 4224kb

input:

1
200000
1 3 3 2 2 3 3 1 2 3 1 1 3 3 3 2 1 1 2 3 2 1 3 3 3 1 2 2 1 3 1 2 1 2 3 2 3 3 2 2 3 2 3 2 3 1 1 1 1 1 3 1 3 2 3 3 3 3 1 3 2 1 3 2 3 2 3 1 1 1 1 3 3 2 3 2 1 2 2 3 2 3 2 2 2 2 2 2 3 2 1 2 2 1 1 3 2 1 2 1 1 3 3 3 2 1 2 2 2 1 3 3 2 3 2 1 3 3 2 2 1 3 1 3 2 1 2 3 2 1 2 3 2 2 3 2 1 2 1 1 1 1 1 1 1 3...

output:

0

result:

wrong answer 1st lines differ - expected: '66691', found: '0'

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #3:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%