답안 #525254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525254 2022-02-11T07:59:52 Z LucaIlie Cat (info1cup19_cat) C++17
25 / 100
882 ms 29584 KB
#include <iostream>
#include <vector>

#define MAX_N 3000000

using namespace std;

int v[MAX_N], p[MAX_N];
vector <pair<int, int>> ans;

int main() {
    int t, n, i;

    cin >> t;
    while ( t-- ) {
        cin >> n;
        for ( i = 0; i < n; i++ ) {
            cin >> v[i];
            v[i]--;
        }
        for ( i = 0; i < n; i++ )
            p[v[i]] = i;

            i = 0;
        while ( i < n / 2 && v[i] + v[n - 1 - i] == n - 1 )
            i++;
        if ( i < n / 2 ) {
            cout << "-1\n";
            continue;
        }

        ans.clear();
        for ( i = 0; i < n / 2; i++ ) {
            if ( v[i] != i ) {
                ans.push_back( { i + 1, p[i] + 1 } );
                p[v[i]] = p[i];
                swap( v[i], v[p[i]] );
                p[v[i]] = i;
            }
        }

        cout << ans.size() << " " << ans.size() << "\n";
        for ( i = 0; i < ans.size(); i++ )
            cout << ans[i].first << " " << ans[i].second << "\n";
    }

    return 0;
}

Compilation message

cat.cpp: In function 'int main()':
cat.cpp:21:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   21 |         for ( i = 0; i < n; i++ )
      |         ^~~
cat.cpp:24:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |             i = 0;
      |             ^
cat.cpp:43:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for ( i = 0; i < ans.size(); i++ )
      |                      ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 332 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 904 KB Output is correct
2 Correct 44 ms 996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 332 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 904 KB Output is correct
2 Correct 44 ms 996 KB Output is correct
3 Correct 878 ms 28240 KB Output is correct
4 Correct 853 ms 27176 KB Output is correct
5 Correct 882 ms 29584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 332 KB Wrong answer
2 Halted 0 ms 0 KB -