提出詳細


ソースコード

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
#define answer(p) printf("Case #%lld:\n",(p)+1);
// #define input(X) getline(cin,X)
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
ll n,m,l;
string s,t;
ll d[200010],e[200010],dp[1001][1001];
int field[200][200];

int movexy[3] = {-1,0,1};

typedef struct pand{
  int x,y;
}hito;

queue<pand> kansen;

void init(){
  rep(i,0,200)rep(j,0,200)field[i][j] = 0;
}

int input(){
  cin >> n >> m;
  lep(i,1,m)lep(j,1,n){
    cin >> field[i][j];
    if(field[i][j] == 2){
      kansen.push((pand){(int)i,(int)j});
    }
  }
  return 0;
}

void bfs(){
  while(!kansen.empty()){
    pand now = kansen.front();kansen.pop();
    rep(i,0,3)rep(j,0,3){
      if(movexy[i] == 0 && movexy[j] == 0)continue;
      if(field[now.x + movexy[i]][now.y + movexy[j]] == 0 || field[now.x + movexy[i]][now.y + movexy[j]] > 1)continue;
      field[now.x + movexy[i]][now.y + movexy[j]] = field[now.x][now.y]+1;
      kansen.push((pand){now.x + movexy[i],now.y + movexy[j]});
    }
  }
}

void ans(){
  int p = 0;
  bool flag_1 = false;
  lep(i,0,m+1){
    lep(j,0,n+1){
      // cout << field[i][j] << " ";
      p = max(field[i][j],p);
      if(field[i][j] == 1)flag_1 = true;
    }
    // puts("");
  }
  if(flag_1)puts("ALIVE");
  else print(p-2);
}

int main(){
  int p;
  cin >> p;
  rep(q,0,p){
    init();
    input();
    bfs();
    answer(q);
    ans();
  }
  return 0;
}

提出情報

提出時間 2018-11-16 16:54:48
問題 F - Pandemic!!!
ユーザ名 miyajima
状態 正解
正解率 50/50
提出出力結果

テストケース情報

# 状態 詳細情報
テストケース 1 正解 詳細を見る
テストケース 2 正解 詳細を見る
テストケース 3 正解 詳細を見る
テストケース 4 正解 詳細を見る
テストケース 5 正解 詳細を見る
テストケース 6 正解 詳細を見る
テストケース 7 正解 詳細を見る
テストケース 8 正解 詳細を見る
テストケース 9 正解 詳細を見る
テストケース 10 正解 詳細を見る
テストケース 11 正解 詳細を見る
テストケース 12 正解 詳細を見る
テストケース 13 正解 詳細を見る
テストケース 14 正解 詳細を見る
テストケース 15 正解 詳細を見る
テストケース 16 正解 詳細を見る
テストケース 17 正解 詳細を見る
テストケース 18 正解 詳細を見る
テストケース 19 正解 詳細を見る
テストケース 20 正解 詳細を見る
テストケース 21 正解 詳細を見る
テストケース 22 正解 詳細を見る
テストケース 23 正解 詳細を見る
テストケース 24 正解 詳細を見る
テストケース 25 正解 詳細を見る
テストケース 26 正解 詳細を見る
テストケース 27 正解 詳細を見る
テストケース 28 正解 詳細を見る
テストケース 29 正解 詳細を見る
テストケース 30 正解 詳細を見る
テストケース 31 正解 詳細を見る
テストケース 32 正解 詳細を見る
テストケース 33 正解 詳細を見る
テストケース 34 正解 詳細を見る
テストケース 35 正解 詳細を見る
テストケース 36 正解 詳細を見る
テストケース 37 正解 詳細を見る
テストケース 38 正解 詳細を見る
テストケース 39 正解 詳細を見る
テストケース 40 正解 詳細を見る
テストケース 41 正解 詳細を見る
テストケース 42 正解 詳細を見る
テストケース 43 正解 詳細を見る
テストケース 44 正解 詳細を見る
テストケース 45 正解 詳細を見る
テストケース 46 正解 詳細を見る
テストケース 47 正解 詳細を見る
テストケース 48 正解 詳細を見る
テストケース 49 正解 詳細を見る
テストケース 50 正解 詳細を見る