提出 #69077858


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s); i <= (t); i ++)
#define per(i, s, t) for(int i = (s); i >= (t); i --)
template<typename T, typename T2>
inline void chmin(T &x, T2 &&y) { x = min(x, y); }
template<typename T, typename T2>
inline void chmax(T &x, T2 &&y) { x = max(x, y); }
typedef long long ll;

const int N = 4e5 + 5;
int n;

int a[N], b[N], v[N], h;
int id[N];
int ans[N];
int mn[N], mx[N];

vector<int> v1, v2;
vector<int> w;

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n;
    rep(i, 1, n)
    {
        cin >> a[i] >> b[i];
        v[++h] = a[i], v[++h] = b[i];
    }
    sort(v + 1, v + h + 1);
    rep(i, 1, n)
    {
        a[i] = lower_bound(v + 1, v + h + 1, a[i]) - v;
        b[i] = lower_bound(v + 1, v + h + 1, b[i]) - v;
        id[a[i]] = id[b[i]] = i;
        mn[i] = min(a[i], b[i]);
        mx[i] = max(a[i], b[i]);
    }
    int lst = n * 2 + 1;
    per(i, n * 2, 1)
    {
        int j = id[i];
        if(mn[j] == i)
        {
            if(mx[j] > lst)
                return cout << "No\n", 0;
        }
        if(mn[j] == i) chmin(lst, mx[j]);
    }
    
    rep(i, 1, n) (a[i] < b[i] ? v1 : v2).push_back(i);
    rep(i, 1, n) if(a[i] > b[i]) w.push_back(a[i]), w.push_back(b[i]);
    sort(v1.begin(), v1.end(), [](int x, int y) { return a[x] > a[y]; });
    sort(v2.begin(), v2.end(), [](int x, int y) { return a[x] < a[y]; });
    sort(w.begin(), w.end());

    for(int i : v1)
    {
        int pos = lower_bound(w.begin(), w.end(), a[i]) - w.begin();
        if(pos != w.size() && w[pos] < b[i])
            return cout << "No\n", 0;
    }

    int idx = 0;
    // for(int i : v1)
    //     cerr << i << " ";
    for(int i : v1) ans[++idx] = i;
    for(int i : v2) ans[++idx] = i;
    cout << "Yes\n";
    rep(i, 1, n) cout << ans[i] << " ";

    return 0;
}

提出情報

提出日時
問題 C - No Collision Moves
ユーザ adam01
言語 C++ 20 (gcc 12.2)
得点 600
コード長 1936 Byte
結果 AC
実行時間 148 ms
メモリ 13300 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:61:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   61 |         if(pos != w.size() && w[pos] < b[i])
      |            ~~~~^~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 3
AC × 27
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3424 KiB
00_sample_01.txt AC 1 ms 3500 KiB
00_sample_02.txt AC 1 ms 3432 KiB
01_handmade_00.txt AC 1 ms 3436 KiB
01_handmade_01.txt AC 1 ms 3452 KiB
01_handmade_02.txt AC 123 ms 11164 KiB
01_handmade_03.txt AC 148 ms 12732 KiB
01_handmade_04.txt AC 136 ms 11940 KiB
01_handmade_05.txt AC 124 ms 11100 KiB
01_handmade_06.txt AC 136 ms 11912 KiB
01_handmade_07.txt AC 137 ms 11908 KiB
02_random_00.txt AC 88 ms 9372 KiB
02_random_01.txt AC 12 ms 4364 KiB
02_random_02.txt AC 34 ms 5848 KiB
02_random_03.txt AC 94 ms 9520 KiB
02_random_04.txt AC 97 ms 9672 KiB
02_random_05.txt AC 96 ms 9804 KiB
02_random_06.txt AC 96 ms 9744 KiB
02_random_07.txt AC 96 ms 9736 KiB
02_random_08.txt AC 36 ms 5904 KiB
02_random_09.txt AC 20 ms 4744 KiB
02_random_10.txt AC 118 ms 10884 KiB
02_random_11.txt AC 84 ms 9204 KiB
02_random_12.txt AC 139 ms 11948 KiB
02_random_13.txt AC 135 ms 11980 KiB
02_random_14.txt AC 139 ms 11928 KiB
02_random_15.txt AC 145 ms 13300 KiB