답안 #1048499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048499 2024-08-08T07:57:17 Z 우민규(#11036) Make them Meet (EGOI24_makethemmeet) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

int n;

void solve() {
    cin >> n;
    vector<int> ref(n);
    iota(ref.begin(), ref.end(), 0);
    vector<vector<int>> queries;
    for (int src = 0; src < (n + 1) / 2; ++src) {
        int i = src + 1, j = (src - 1 + n) % n;
        vector<int> query(n, 0);
        int num_colors = 1;
        while (i != j) {
            query[ref[i]] = query[ref[j]] = num_colors;
            swap(ref[i], ref[j]);
            num_colors += 1;

            i = (i + 1) % n;
            j = (j - 1 + n) % n;
            if ((j + 1) % n == i) break;
        }
        queries.push_back(query);
    }
    for (int src = 0; src < (n + 1) / 2; ++src) {
        int i = src + 1, j = src;
        vector<int> query(n, 0);
        int num_colors = 1;
        while (i != j) {
            query[ref[i]] = query[ref[j]] = num_colors;
            swap(ref[i], ref[j]);
            num_colors += 1;

            i = (i + 1) % n;
            j = (j - 1 + n) % n;

            if (i == (j + 1) % n) break;
        }
        queries.push_back(query);
    }
    auto p = [&](vector<int> s) { s.resize(n); for (auto c : s) cout << c << " "; cout << "\n"; };
    cout << queries.size() << "\n";
    for (auto q : queries) p(q);
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    solve();
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:49:9: warning: unused variable 't' [-Wunused-variable]
   49 |     int t = 1;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB If people start at 0 and 2, then they can avoid each other
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB If people start at 0 and 2, then they can avoid each other
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB If people start at 0 and 2, then they can avoid each other
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB If people start at 0 and 2, then they can avoid each other
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB If people start at 0 and 2, then they can avoid each other
3 Halted 0 ms 0 KB -