Submission #4027547


Source Code Expand

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1e9
#define MOD 1e9+7
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, int, int> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

ll c[101][101];
ll COUNT[101];

struct Node{
  ll id, dist;
  Node(ll a, ll b){
    id = a;
    dist = b;
  }
  bool operator <(const Node& another) const
  {
    return dist < another.dist;
  }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll a,b;
  cin>>a>>b;
  ll M;
  cin>>M;
  REP(i,101){
    COUNT[i]=0;
    REP(j,101){
    if(i==j) c[i][j]=0;
    else c[i][j]=INF;
    }
  }
  REP(i,M){
    ll x,y;
    cin>>x>>y;
    c[x][y] = c[y][x] = 1;
  }

  //ワーシャルフロイド
  REP(k,101){
    REP(j,101){
      REP(i,101){
        c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  //aからの距離で最短順にソート
  vector<Node>from_a;
  REP(i,101){
    if(a!=i && c[a][i]!=INF){
      auto node = Node(i,c[a][i]);
      from_a.push_back(node);
    }
  }
  VSORT(from_a)
  REP(i,101){
    if(a!=i && c[a][i]==1) COUNT[i]=1;
  }
  for(auto node : from_a){
    ll id=node.id;
    REP(i,101){
      if(c[id][i]==1 && c[a][i] == node.dist+1){
        COUNT[i] += COUNT[id];
        COUNT[i] %= MOD;
      }
    }
  }
  cout << COUNT[b] << endl;
}

Submission Info

Submission Time
Task C - 正直者の高橋くん
User Bondo416
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1907 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:89:18: error: invalid operands of types ‘long long int’ and ‘double’ to binary ‘operator%’
         COUNT[i] %= MOD;
                  ^
./Main.cpp:89:18: error:   in evaluation of ‘operator%=(long long int, double)’