結果

問題 No.2301 Namorientation
ユーザー hiro71687khiro71687k
提出日時 2023-05-16 19:17:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,011 ms / 3,000 ms
コード長 1,427 bytes
コンパイル時間 5,041 ms
コンパイル使用メモリ 276,820 KB
実行使用メモリ 46,744 KB
最終ジャッジ日時 2024-05-08 13:26:10
合計ジャッジ時間 28,029 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 529 ms
24,320 KB
testcase_13 AC 468 ms
22,272 KB
testcase_14 AC 1,006 ms
38,144 KB
testcase_15 AC 595 ms
26,496 KB
testcase_16 AC 816 ms
33,152 KB
testcase_17 AC 550 ms
25,088 KB
testcase_18 AC 825 ms
33,920 KB
testcase_19 AC 431 ms
21,120 KB
testcase_20 AC 823 ms
33,536 KB
testcase_21 AC 576 ms
26,240 KB
testcase_22 AC 610 ms
32,896 KB
testcase_23 AC 605 ms
32,512 KB
testcase_24 AC 504 ms
27,776 KB
testcase_25 AC 546 ms
36,632 KB
testcase_26 AC 709 ms
46,744 KB
testcase_27 AC 966 ms
38,400 KB
testcase_28 AC 986 ms
38,400 KB
testcase_29 AC 986 ms
38,400 KB
testcase_30 AC 996 ms
38,272 KB
testcase_31 AC 1,011 ms
38,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=14449999999999;
ll mod=998244353;
int main(){
    ll n;
    cin >> n;
    vector<vector<ll>>g(n);
    vector<ll>x(n),y(n);
    set<pair<ll,ll>>s;
    for (ll i = 0; i < n; i++)
    {
        ll a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
        x[i]=a;
        y[i]=b;
    }
    vector<ll>memo(n);
    for (ll i = 0; i < n; i++)
    {
        memo[i]=g[i].size();
        s.insert({memo[i],i});
    }
    vector<ll>m(n,0);
    map<pair<ll,ll>,ll>mp;
    while (!s.empty())
    {
        auto v=s.lower_bound({-inf,1});
        pair<ll,ll>p=*(v);
        m[p.second]=1;
        s.erase(p);
        m[p.second]=1;
        for (ll i = 0; i < g[p.second].size(); i++)
        {
            if (m[g[p.second][i]]==0&&memo[g[p.second][i]]>1)
            {
                mp[{p.second,g[p.second][i]}]=1;
                s.erase({memo[g[p.second][i]],g[p.second][i]});
                memo[g[p.second][i]]-=1;
                s.insert({memo[g[p.second][i]],g[p.second][i]});

                break;
            }
        }
    }
    for (ll i = 0; i < n; i++)
    {
        if (mp[{x[i],y[i]}]==1)
        {
            cout << "->" << endl;
        }else{
            cout << "<-" << endl;
        }
    }
}
0