Submission #568251

# Submission time Handle Problem Language Result Execution time Memory
568251 2022-05-25T03:19:46 Z almothana05 Restore Array (RMI19_restore) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 10000000000000000
using namespace std;
// vector<pair<int , int> >gr[2000000];
long long dist[2000000] ;
// priority_queue<pair<int , int> >q;
vector<int>edge[3];
int main(){
   
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int menge , numm , nummer , que , cmp , bi;
   cin >> menge >> que;
   for(int i = 0 ; i < menge;  i++){

      edge.push_back({i , i + 1 , 1});
      edge.push_back({i + 1, i , 0});

   }
   while(que--){
      cin >> numm >> nummer >> cmp >> bi;
      // numm++;
      nummer++;
      if(bi == 0){
         cmp = nummer - numm - cmp;
         edge.push_back({numm , nummer , cmp});
      }
      else{
         cmp = nummer - numm - cmp + 1;
         cmp *= -1;
         edge.push_back({nummer , numm , cmp});
      }
   }
   for(int i = 0 ; i < 20000 ; i++){
      dist[i] = inf;
   }
   dist[0] = 0;
   for(int k = 0 ; k < menge ; k++){
      for(int i = 0 ; i < edge.size() ; i++){
         if(dist[edge[0][i]] != inf && dist[edge[0][i]] + edge[2][i] < dist[edge[1][i]]){
            dist[edge[1][i]] = dist[edge[0][i]] + edge[2][i];
         }
      }
   }
   for(int i = 0 ; i < edge.size() ; i++){
      if(dist[edge[0][i]] != inf && dist[edge[0][i]] + edge[2][i] < dist[edge[1][i]]){
         cout << -1 << "\n";
         return 0;
      }
   }
   for(int i = 0 ; i < menge ; i++){
      // cout << dist[i] << "\n";
      if(dist[i] == dist[i + 1]){
         cout << 0 << ' ';
      }
      else{
         cout << 1 << ' ';
      }
   }

}

Compilation message

restore.cpp: In function 'int main()':
restore.cpp:17:12: error: request for member 'push_back' in 'edge', which is of non-class type 'std::vector<int> [3]'
   17 |       edge.push_back({i , i + 1 , 1});
      |            ^~~~~~~~~
restore.cpp:18:12: error: request for member 'push_back' in 'edge', which is of non-class type 'std::vector<int> [3]'
   18 |       edge.push_back({i + 1, i , 0});
      |            ^~~~~~~~~
restore.cpp:27:15: error: request for member 'push_back' in 'edge', which is of non-class type 'std::vector<int> [3]'
   27 |          edge.push_back({numm , nummer , cmp});
      |               ^~~~~~~~~
restore.cpp:32:15: error: request for member 'push_back' in 'edge', which is of non-class type 'std::vector<int> [3]'
   32 |          edge.push_back({nummer , numm , cmp});
      |               ^~~~~~~~~
restore.cpp:40:32: error: request for member 'size' in 'edge', which is of non-class type 'std::vector<int> [3]'
   40 |       for(int i = 0 ; i < edge.size() ; i++){
      |                                ^~~~
restore.cpp:46:29: error: request for member 'size' in 'edge', which is of non-class type 'std::vector<int> [3]'
   46 |    for(int i = 0 ; i < edge.size() ; i++){
      |                             ^~~~