Language: C++

#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
#define MAX 1e9
int INF=MAX*MAX;
??
typedef pair<int,int> pii;
typedef pair<pii,long long> piii;
vector<vector<long long>>d(501,vector<long long>(51,INF));
signed main(){
????????int n,m;?? cin>>n>>m;
????????vector<vector<pii>>edge(n,vector<pii>());
????????rep(i,m){
????????????????int a,b,c; cin>>a>>b>>c;
????????????????--a,--b;
????????????????edge[a].push_back(pii(b,c));
????????????????edge[b].push_back(pii(a,c));
????????}
????????int v0,a,b,c; cin>>v0>>a>>b>>c;
????????priority_queue<piii,vector<piii>,greater<piii>>que;
????????d[0][v0]=0;
????????que.push(piii(pii(0,0),v0));
????????while(!que.empty()){
????????????????piii now=que.top(); que.pop();
????????????????int v=now.second;
????????????????int _v=(v*a+b)%c;
????????????????if(d[now.first.second][v]<now.first.first)continue;
????????????????for(int i=0; i<edge[now.first.second].size();i++){
????????????????????????pii next=edge[now.first.second][i];
????????????????????????if(d[next.first][_v]<now.first.first+next.second*v)continue;
????????????????????????d[next.first][_v]=now.first.first+next.second*v;
????????????????????????que.push(piii(pii(d[next.first][_v],next.first),_v));
????????????????}
????????}
????????int ans=INF;
????????rep(i,51)if(d[n-1][i]!=INF){
????????????????vector<vector<long long>>_d(501,vector<long long>(51,INF));
????????????????_d[n-1][i]=d[n-1][i];
????????????????que.push(piii(pii(d[n-1][i],n-1),i));
????????????????while(!que.empty()){
????????????????????????piii now=que.top(); que.pop();
????????????????????????int v=now.second;
????????????????????????int _v=(v*a+b)%c;
????????????????????????if(_d[now.first.second][v]<now.first.first)continue;
????????????????????????for(int i=0; i<edge[now.first.second].size();i++){
????????????????????????????????pii next=edge[now.first.second][i];
????????????????????????????????if(_d[next.first][_v]<now.first.first+next.second*v)continue;
????????????????????????????????_d[next.first][_v]=now.first.first+next.second*v;
????????????????????????????????que.push(piii(pii(_d[next.first][_v],next.first),_v));
????????????????????????}
????????????????}
????????????????rep(i,51)ans=min(ans,_d[0][i]);
????????}
????????cout<<ans<<endl;
}

Compiler output:
a.cc:16:15: warning: trigraph ??- ignored, use -trigraphs to enable [-Wtrigraphs]
   16 | ????????????????--a,--b;
a.cc:7:1: error: expected unqualified-id before '?' token
    7 | ??
      | ^
a.cc:9:14: error: 'pii' was not declared in this scope
    9 | typedef pair<pii,long long> piii;
      |              ^~~
a.cc:9:27: error: template argument 1 is invalid
    9 | typedef pair<pii,long long> piii;
      |                           ^
a.cc: In function 'int main()':
a.cc:12:1: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      | ^
a.cc:12:2: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |  ^
a.cc:12:3: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |   ^
a.cc:12:4: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |    ^
a.cc:12:5: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |     ^
a.cc:12:6: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |      ^
a.cc:12:7: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |       ^
a.cc:12:8: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |        ^
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:9: error: expected ':' before 'long'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^
      |         :
a.cc:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:12:9: note: in expansion of macro 'int'
   12 | ????????int n,m;?? cin>>n>>m;
      |         ^~~
a.cc:12:17: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |                 ^
a.cc:12:18: error: expected primary-expression before '?' token
   12 | ????????int n,m;?? cin>>n>>m;
      |                  ^
a.cc:12:25: error: 'n' was not declared in this scope; did you mean 'yn'?
   12 | ????????int n,m;?? cin>>n>>m;
      |                         ^
      |                         yn
a.cc:12:28: error: 'm' was not declared in this scope; did you mean 'tm'?
   12 | ????????int n,m;?? cin>>n>>m;
      |                            ^
      |                            tm
a.cc:12:29: error: expected ':' before ';' token
   12 | ????????int n,m;?? cin>>n>>m;
      |                             ^
      |                             :
a.cc:12:29: error: expected primary-expression before ';' token
a.cc:12:29: error: expected ':' before ';' token
   12 | ????????int n,m;?? cin>>n>>m;
      |                             ^
      |                             :
a.cc:12:29: error: expected primary-expression before ';' token
a.cc:13:1: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      | ^
a.cc:13:2: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |  ^
a.cc:13:3: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |   ^
a.cc:13:4: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |    ^
a.cc:13:5: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |     ^
a.cc:13:6: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |      ^
a.cc:13:7: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |       ^
a.cc:13:8: error: expected primary-expression before '?' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |        ^
a.cc:13:23: error: 'pii' was not declared in this scope; did you mean 'piii'?
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                       ^~~
      |                       piii
a.cc:13:23: error: template argument 1 is invalid
a.cc:13:23: error: template argument 2 is invalid
a.cc:13:26: error: template argument 1 is invalid
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                          ^~
a.cc:13:26: error: template argument 2 is invalid
a.cc:13:28: error: expected ':' before 'edge'
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                            ^~~~
      |                            :
a.cc:13:45: error: template argument 2 is invalid
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                             ^
a.cc:13:28: error: 'edge' was not declared in this scope
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                            ^~~~
a.cc:13:49: error: expected ':' before ';' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                                 ^
      |                                                 :
a.cc:13:49: error: expected primary-expression before ';' token
a.cc:13:49: error: expected ':' before ';' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                                 ^
      |                                                 :
a.cc:13:49: error: expected primary-expression before ';' token
a.cc:13:49: error: expected ':' before ';' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                                 ^
      |                                                 :
a.cc:13:49: error: expected primary-expression before ';' token
a.cc:13:49: error: expected ':' before ';' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                                 ^
      |                                                 :
a.cc:13:49: error: expected primary-expression before ';' token
a.cc:13:49: error: expected ':' before ';' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                                 ^
      |                                                 :
a.cc:13:49: error: expected primary-expression before ';' token
a.cc:13:49: error: expected ':' before ';' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                                 ^
      |                                                 :
a.cc:13:49: error: expected primary-expression before ';' token
a.cc:13:49: error: expected ':' before ';' token
   13 | ????????vector<vector<pii>>edge(n,vector<pii>());
      |                                                 ^
      |                                                 :
a.cc:13:49: error: expected primary-expression before ';' token
a.cc:14:1: error: expected primary-expression before '?' token
   14 | ????????rep(i,m){
      | ^
a.cc:14:2: error: expected primary-expression before '?' token
   14 | ????????rep(i,m){
      |  ^
a.cc:14:3: error: expected primary-expression before '?' token
   14 | ????????rep(i,m){
      |   ^
a.cc:14:4: error: expected primary-expression before '?' token
   14 | ????????rep(i,m){
      |    ^
a.cc:14:5: error: expected primary-expression before '?' token
   14 | ????????rep(i,m){
      |     ^
a.cc:14:6: error: expected primary-expression before '?' token
   14 | ????????rep(i,m){
      |      ^
a.cc:14:7: error: expected primary-expression before '?' token
   14 | ????????rep(i,m){
      |       ^
a.cc:14:8: error: expected primary-expression before '?' toke