/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Wrong Answer 2ms 532.0 KiB

Code

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        
        vector<int> perm(n + 1);
        vector<bool> used(n + 1, false);
        
        // Estratégia gulosa: para cada posição, colocar o menor número disponível
        // que não seja igual à posição atual
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (!used[j] && j != i) {
                    perm[i] = j;
                    used[j] = true;
                    break;
                }
            }
        }
        
        // Imprimir resultado
        for (int i = 1; i <= n; i++) {
            cout << perm[i];
            if (i < n) cout << " ";
        }
        cout << "\n";
    }
    
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1210 A. Smallest Permutation
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 17:22:52
Judged At
2025-07-14 17:22:52
Judged By
Score
0
Total Time
2ms
Peak Memory
532.0 KiB