結果

問題 No.1647 Travel in Mitaru city 2
ユーザー auauaauaua
提出日時 2021-08-13 22:06:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,543 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 175,964 KB
実行使用メモリ 34,240 KB
最終ジャッジ日時 2024-04-14 18:07:45
合計ジャッジ時間 20,204 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,476 KB
testcase_01 AC 6 ms
9,460 KB
testcase_02 AC 5 ms
9,708 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 5 ms
9,580 KB
testcase_06 AC 6 ms
9,484 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 287 ms
27,776 KB
testcase_13 AC 292 ms
28,652 KB
testcase_14 WA -
testcase_15 AC 354 ms
33,056 KB
testcase_16 AC 324 ms
31,384 KB
testcase_17 AC 274 ms
28,464 KB
testcase_18 AC 309 ms
28,400 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 370 ms
33,768 KB
testcase_24 AC 327 ms
31,424 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 378 ms
34,112 KB
testcase_29 WA -
testcase_30 AC 361 ms
32,932 KB
testcase_31 WA -
testcase_32 AC 321 ms
33,516 KB
testcase_33 AC 330 ms
31,660 KB
testcase_34 AC 375 ms
34,112 KB
testcase_35 AC 348 ms
32,444 KB
testcase_36 WA -
testcase_37 AC 366 ms
34,240 KB
testcase_38 AC 323 ms
30,872 KB
testcase_39 AC 307 ms
29,176 KB
testcase_40 AC 350 ms
30,580 KB
testcase_41 WA -
testcase_42 AC 350 ms
30,808 KB
testcase_43 AC 6 ms
9,520 KB
testcase_44 AC 6 ms
9,580 KB
testcase_45 WA -
testcase_46 AC 274 ms
26,124 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=200010;
const double PI=acos(-1.0);
typedef vector<vector<ll> > mat;
typedef vector<ll> vec;

vector<vector<ll> > G(MAX);
vector<ll>ans(0);
vector<ll>used(MAX);
ll st=-1;
ll cnt=0;
void dfs(ll i, ll p){
    used[i]=1;
    for(auto e:G[i]){
        if(e==p)continue;
        if(used[e]==1){
            st=e;
            ans.pb(e);
            break;
        }
        dfs(e,i);
        if(st!=-1)break;
    }
    if(st==-2)return;
    if(st!=-1)ans.pb(i);
    if(st==i)st=-2;
}

signed main(){
    ll h,w,n;cin>>h>>w>>n;
    map<pll,ll>ma;
    rep(i,n){
        ll x,y;cin>>x>>y;
        x--;y--;
        G[x].pb(h+y);
        G[h+y].pb(x);
        ma[mp(x,h+y)]=i;
        ma[mp(h+y,x)]=i;
    }
    dfs(0,-1);
    if(st==-1){
        cout<<-1<<endl;
    }else{
        cout<<ans.size()-1<<endl;
        rep(i,ans.size()-1){
            cout<<ma[mp(ans[i],ans[i+1])]+1<<' ';
        }
        cout<<endl;
    }
}
0