Submission #2697250


Source Code Expand

#include<iostream>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define MAX 100005
int main(){
  int n,m,s,t,di;
  cin >> n >> m >> s >> t;
  int i,j,k;
  vector<int> v[MAX];
  ll d[MAX]={},d2[MAX]={};
  for(i=0;i<m;i++){
    cin >> j >> k;
    v[j].push_back(k);
    v[k].push_back(j);
  }

  bool used[MAX]={},used2[MAX]={};
  queue<P> q;
  P p,b;
  p.first=s;
  p.second=0;
  q.push(p);
  while(!q.empty()){
    p=q.front();q.pop();
    if(used[p.first]) continue;
    //cout << p.first << ":" << p.second << endl;
    if(p.first==t) di=p.second;
    used[p.first]=true;
    d[p.second]++;
    b.second=p.second+1;
    for(i=0;i<v[p.first].size();i++){
      b.first=v[p.first][i];
      q.push(b);
    }
  }
  p.first=t;
  p.second=0;
  q.push(p);
  while(!q.empty()){
    p=q.front();q.pop();
    if(used2[p.first]) continue;
    //cout << p.first << ":" << p.second << endl;
    used2[p.first]=true;
    d2[p.second]++;
    b.second=p.second+1;
    for(i=0;i<v[p.first].size();i++){
      b.first=v[p.first][i];
      q.push(b);
    }
  }
  
  //cout << di << endl;
  ll o=0;
  
  for(i=0;i<di-1;i++){
    o+=d[i]*d2[di-2-i];
  }
  
  cout << o << endl;
  return 0;
}

Submission Info

Submission Time
Task B - Minus One
User beet
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1309 Byte
Status AC
Exec Time 147 ms
Memory 9848 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 73
Set Name Test Cases
All 00-sample1.txt, 00-sample2.txt, 00-sample4.txt, 50-random10.txt, 50-random11.txt, 50-random12.txt, 50-random13.txt, 50-random14.txt, 50-random15.txt, 50-random16.txt, 50-random17.txt, 50-random18.txt, 50-random19.txt, 50-random20.txt, 50-random21.txt, 50-random22.txt, 50-random23.txt, 50-random24.txt, 50-random25.txt, 50-random26.txt, 50-random27.txt, 50-random28.txt, 50-random29.txt, 50-random30.txt, 50-random31.txt, 50-random32.txt, 50-random33.txt, 50-random34.txt, 50-random35.txt, 50-random36.txt, 50-random37.txt, 50-random38.txt, 50-random39.txt, 50-random40.txt, 50-random41.txt, 50-random42.txt, 50-random43.txt, 50-random44.txt, 50-random45.txt, 50-random46.txt, 50-random47.txt, 50-random48.txt, 50-random49.txt, 50-random50.txt, 50-random51.txt, 50-random52.txt, 50-random53.txt, 50-random54.txt, 50-random55.txt, 50-random56.txt, 50-random57.txt, 50-random58.txt, 50-random59.txt, 50-random60.txt, 50-random61.txt, 50-random62.txt, 50-random63.txt, 50-random64.txt, 50-random65.txt, 50-random66.txt, 50-random67.txt, 50-random68.txt, 50-random69.txt, intoverflow00.txt, intoverflow01.txt, intoverflow02.txt, intoverflow03.txt, intoverflow04.txt, intoverflow05.txt, intoverflow06.txt, intoverflow07.txt, intoverflow08.txt, intoverflow09.txt
Case Name Status Exec Time Memory
00-sample1.txt AC 3 ms 4352 KB
00-sample2.txt AC 3 ms 4352 KB
00-sample4.txt AC 3 ms 4352 KB
50-random10.txt AC 3 ms 4352 KB
50-random11.txt AC 3 ms 4352 KB
50-random12.txt AC 3 ms 4352 KB
50-random13.txt AC 3 ms 4352 KB
50-random14.txt AC 3 ms 4352 KB
50-random15.txt AC 3 ms 4352 KB
50-random16.txt AC 3 ms 4352 KB
50-random17.txt AC 3 ms 4352 KB
50-random18.txt AC 3 ms 4352 KB
50-random19.txt AC 3 ms 4352 KB
50-random20.txt AC 3 ms 4352 KB
50-random21.txt AC 3 ms 4352 KB
50-random22.txt AC 3 ms 4352 KB
50-random23.txt AC 3 ms 4352 KB
50-random24.txt AC 3 ms 4352 KB
50-random25.txt AC 3 ms 4352 KB
50-random26.txt AC 3 ms 4352 KB
50-random27.txt AC 3 ms 4352 KB
50-random28.txt AC 3 ms 4352 KB
50-random29.txt AC 3 ms 4352 KB
50-random30.txt AC 3 ms 4352 KB
50-random31.txt AC 3 ms 4352 KB
50-random32.txt AC 3 ms 4352 KB
50-random33.txt AC 3 ms 4352 KB
50-random34.txt AC 3 ms 4352 KB
50-random35.txt AC 3 ms 4352 KB
50-random36.txt AC 3 ms 4352 KB
50-random37.txt AC 3 ms 4352 KB
50-random38.txt AC 3 ms 4352 KB
50-random39.txt AC 3 ms 4352 KB
50-random40.txt AC 4 ms 4480 KB
50-random41.txt AC 3 ms 4352 KB
50-random42.txt AC 3 ms 4352 KB
50-random43.txt AC 3 ms 4352 KB
50-random44.txt AC 3 ms 4352 KB
50-random45.txt AC 3 ms 4352 KB
50-random46.txt AC 3 ms 4352 KB
50-random47.txt AC 3 ms 4352 KB
50-random48.txt AC 3 ms 4352 KB
50-random49.txt AC 3 ms 4352 KB
50-random50.txt AC 7 ms 4608 KB
50-random51.txt AC 14 ms 4864 KB
50-random52.txt AC 5 ms 4480 KB
50-random53.txt AC 12 ms 4736 KB
50-random54.txt AC 14 ms 4864 KB
50-random55.txt AC 15 ms 4864 KB
50-random56.txt AC 3 ms 4352 KB
50-random57.txt AC 9 ms 4608 KB
50-random58.txt AC 7 ms 4608 KB
50-random59.txt AC 7 ms 4480 KB
50-random60.txt AC 80 ms 7296 KB
50-random61.txt AC 78 ms 7296 KB
50-random62.txt AC 128 ms 9088 KB
50-random63.txt AC 80 ms 7296 KB
50-random64.txt AC 85 ms 7424 KB
50-random65.txt AC 30 ms 5504 KB
50-random66.txt AC 28 ms 5504 KB
50-random67.txt AC 10 ms 4736 KB
50-random68.txt AC 10 ms 4608 KB
50-random69.txt AC 5 ms 4480 KB
intoverflow00.txt AC 141 ms 9848 KB
intoverflow01.txt AC 142 ms 9844 KB
intoverflow02.txt AC 144 ms 9840 KB
intoverflow03.txt AC 138 ms 9848 KB
intoverflow04.txt AC 147 ms 9844 KB
intoverflow05.txt AC 145 ms 9844 KB
intoverflow06.txt AC 140 ms 9844 KB
intoverflow07.txt AC 145 ms 9848 KB
intoverflow08.txt AC 141 ms 9848 KB
intoverflow09.txt AC 142 ms 9848 KB