結果

問題 No.340 雪の足跡
ユーザー 小指が強い人小指が強い人
提出日時 2016-01-31 10:26:44
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,957 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 173,580 KB
実行使用メモリ 84,300 KB
最終ジャッジ日時 2023-10-21 18:17:49
合計ジャッジ時間 11,221 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
67,636 KB
testcase_01 AC 23 ms
63,252 KB
testcase_02 AC 23 ms
63,252 KB
testcase_03 AC 23 ms
63,252 KB
testcase_04 AC 25 ms
63,252 KB
testcase_05 AC 23 ms
63,252 KB
testcase_06 AC 23 ms
63,252 KB
testcase_07 AC 23 ms
63,252 KB
testcase_08 AC 24 ms
63,252 KB
testcase_09 AC 23 ms
63,252 KB
testcase_10 AC 23 ms
63,256 KB
testcase_11 AC 29 ms
63,492 KB
testcase_12 AC 26 ms
63,832 KB
testcase_13 AC 30 ms
64,164 KB
testcase_14 AC 786 ms
80,520 KB
testcase_15 AC 702 ms
81,404 KB
testcase_16 AC 403 ms
71,548 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < n; i++)
#define rep(i, n) REP(i, 0, n)

template<class T> T read(){T a;cin >> a;return a;}
template<class T> T read(T& a){cin >> a;}
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << a << endl;}
void write(double a){cout << fixed << setprecision(12) << a << endl;}
template<class T> void warr(T a, int n, char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}

int main(void)
{
    int w,h,n;
    Hash<int,bool>* a=new Hash<int,bool>[1000*1000];
    cin>>w>>h>>n;
    rep(i,n) {
        int m=read<int>();
        int bf=read<int>();
        rep(j,m){
            int b=read<int>();
            int sign=(b<bf)?1:-1;
            int sb=b;
            if(b%w==bf%w)
                while(sb!=bf){
                    a[sb][sb+w*sign]=a[sb+w*sign][sb]=true;
                    sb+=w*sign;
                }
            else
                while(sb!=bf){
                    a[sb][sb+sign]=a[sb+sign][sb]=true;
                    sb+=sign;
                }
            bf=b;
        }
    }
    bool vis[1000*1000]={0};
    queue<int> q;
    int res[1000*1000]={0};
    int WH=w*h-1;
    q.push(0);
    vis[0]=true;
    while(!q.empty()){
        int cur=q.front();
        q.pop();
        for(auto p : a[cur]){
            if(!vis[p.first]){
                vis[p.first]=true;
                res[p.first]=res[cur]+1;
                q.push(p.first);
            }
        }
        if(vis[WH])
            break;
    }
    if(vis[WH])
        write(res[WH]);
    else
        write("Odekakedekinai..");
	return 0;
}
0