답안 #1048462

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

int n;

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

            i = (i + 1) % n0;
            j = (j - 1 + n0) % n0;
        }
        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:47:9: warning: unused variable 't' [-Wunused-variable]
   47 |     int t = 1;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB If people start at 0 and 3, then they can avoid each other
4 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 Incorrect 0 ms 348 KB If people start at 0 and 3, 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 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB If people start at 0 and 3, then they can avoid each other
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB If people start at 0 and 3, then they can avoid each other
4 Halted 0 ms 0 KB -