답안 #1048505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048505 2024-08-08T08:00:16 Z 우민규(#11036) Make them Meet (EGOI24_makethemmeet) C++17
13 / 100
1 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;
        }
        for (int i = 0; i < n; ++i) {
            if (query[i] == 0) {
                query[i] = num_colors;
                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:55:9: warning: unused variable 't' [-Wunused-variable]
   55 |     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 1 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 344 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 -