提出 #44571647


ソースコード 拡げる

#include "bits/stdc++.h"
using namespace std;
int n, sz;
vector<int> tmp, ans;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    if (n % 2 == 0) {
        for (int i = 1; i <= n; ++i) {
            if (i & 1) for (int j = n; j >= i; --j) tmp.push_back(j);
            else for (int j = i; j < n; ++j) tmp.push_back(j);
        }
    } else {
        for (int i = 1; i < n; ++i) {
            for (int j = n; j >= i; j -= 2) tmp.push_back(j);
            for (int j = i+i%2; j < n; j += 2) tmp.push_back(j);
        }
    }
    sz = tmp.size();
    for (int i = 0; i < tmp.size(); ++i) {
        if (i > 0 && sz < n*(n+1)/2
            && ((tmp[i-1] == n-1 && tmp[i] == n-2)
            || (tmp[i-1] == n-2 && tmp[i] == n-1))) {
                ans.push_back(n);
                ++sz;
            }
        ans.push_back(tmp[i]);
    }
    for (int &i: ans) cout << i << " ";
}

提出情報

提出日時
問題 A - i i's
ユーザ cheatkhitacontre
言語 C++ 20 (gcc 12.2)
得点 400
コード長 942 Byte
結果 AC
実行時間 25 ms
メモリ 8136 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:20:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   20 |     for (int i = 0; i < tmp.size(); ++i) {
      |                     ~~^~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 1
AC × 28
セット名 テストケース
Sample example0.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, example0.txt
ケース名 結果 実行時間 メモリ
000.txt AC 1 ms 3432 KiB
001.txt AC 1 ms 3412 KiB
002.txt AC 1 ms 3484 KiB
003.txt AC 1 ms 3436 KiB
004.txt AC 1 ms 3440 KiB
005.txt AC 11 ms 5388 KiB
006.txt AC 1 ms 3528 KiB
007.txt AC 18 ms 7604 KiB
008.txt AC 15 ms 7240 KiB
009.txt AC 5 ms 4060 KiB
010.txt AC 2 ms 3440 KiB
011.txt AC 1 ms 3496 KiB
012.txt AC 3 ms 3556 KiB
013.txt AC 6 ms 4356 KiB
014.txt AC 7 ms 4356 KiB
015.txt AC 11 ms 5412 KiB
016.txt AC 1 ms 3580 KiB
017.txt AC 4 ms 4060 KiB
018.txt AC 24 ms 7992 KiB
019.txt AC 20 ms 7836 KiB
020.txt AC 11 ms 5356 KiB
021.txt AC 6 ms 4364 KiB
022.txt AC 13 ms 5596 KiB
023.txt AC 9 ms 5108 KiB
024.txt AC 6 ms 4124 KiB
025.txt AC 25 ms 8136 KiB
026.txt AC 25 ms 7948 KiB
example0.txt AC 1 ms 3312 KiB