QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#568922#9313. Make MaxyylxWA 0ms3624kbC++14863b2024-09-16 19:16:462024-09-16 19:16:46

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-16 19:16:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-09-16 19:16:46]
  • 提交

answer

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int t;
    cin >> t;  // Number of test cases
    
    while (t--) {
        int n;
        cin >> n;  // Length of the array
        
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];  // Array elements
        }

        int operations = 0;
        int last_pos = n - 1;

        // Start from the end of the array and look for the first non-uniform subarray
        while (last_pos > 0) {
            if (a[last_pos] != a[last_pos - 1]) {
                operations++;
                last_pos = last_pos - (n - last_pos);  // Move back to the length of the largest group found
            } else {
                last_pos--;
            }
        }

        cout << operations << endl;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3624kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1
0
1
2

result:

wrong answer 3rd numbers differ - expected: '3', found: '1'