正文
增加 29 行删除 0 行
15 行未改动16171819202122232425262715 行未改动}return b;}matrix operator^(const long long& x) const{if(x==1) return *this;matrix b=*this^(x>>1);b=b*b;if(x&1) b=b**this;return b;}};```15 行未改动161718192021222324252627282930313233343536373839404142434445464748495051525354555615 行未改动}return b;}matrix operator^(const long long& x) const{if(x==0){matrix b(h,w);for(int i=1;i<=h;++i){b.a[i][i]=1;}return b;}if(x==1) return *this;matrix b=*this^(x>>1);b=b*b;if(x&1) b=b**this;return b;}};```---AI Dijiskra```cppauto dij=[&](int s){vector<ll> d(n+1,-1);priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;d[s]=0;q.push({0,s});while(!q.empty()){auto [t,x]=q.top();q.pop();if(t>d[x])continue;for(auto [y,w]:g[x]){if(d[y]==-1||d[y]>d[x]+w){d[y]=d[x]+w;q.push({d[y],y});}}}return d;};```