제출 #525254

#제출 시각아이디문제언어결과실행 시간메모리
525254LucaIlieCat (info1cup19_cat)C++17
25 / 100
882 ms29584 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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++ )
      |                      ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...