Submission #1317212

#TimeUsernameProblemLanguageResultExecution timeMemory
1317212huseynahmadli2010Dreaming (IOI13_dreaming)C++20
Compilation error
0 ms0 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; #define int long long; const int sz=1e6+5; vector<pair<int,int>> graph[sz]; bool visited[sz]; int sum=0; void dfs(int v) { visited[v]=true; for(auto &[to,w] : graph[v]) { if(!visited[to]) { dfs(to); sum+=w; } } } int travelTime(int n,int m,int l,int a[],int b[],int t[]) { for(int i=0;i<m;i++) { graph[a[i]].push_back({b[i],t[i]}); graph[b[i]].push_back({a[i],t[i]}); } vector<int> res; for(int i=0;i<n;i++) { if(!visited[i]) { dfs(i); res.push_back(sum); sum=0; } } if(res.size()==1) return res[0]; sort(res.rbegin(),res.rend()); return (res[0]+res[1]+l); }

Compilation message (stderr)

dreaming.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
dreaming.cpp:8:7: note: in expansion of macro 'int'
    8 | const int sz=1e6+5;
      |       ^~~
dreaming.cpp:8:11: error: 'sz' does not name a type
    8 | const int sz=1e6+5;
      |           ^~
dreaming.cpp:6:18: error: wrong number of template arguments (1, should be 2)
    6 | #define int long long;
      |                  ^~~~
dreaming.cpp:10:13: note: in expansion of macro 'int'
   10 | vector<pair<int,int>> graph[sz];
      |             ^~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from dreaming.cpp:2:
/usr/include/c++/13/bits/stl_pair.h:187:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
  187 |     struct pair
      |            ^~~~
dreaming.cpp:10:8: error: template argument 1 is invalid
   10 | vector<pair<int,int>> graph[sz];
      |        ^
dreaming.cpp:10:8: error: template argument 2 is invalid
dreaming.cpp:10:16: error: expected unqualified-id before ',' token
   10 | vector<pair<int,int>> graph[sz];
      |                ^
dreaming.cpp:6:13: error: expected unqualified-id before 'long'
    6 | #define int long long;
      |             ^~~~
dreaming.cpp:10:17: note: in expansion of macro 'int'
   10 | vector<pair<int,int>> graph[sz];
      |                 ^~~
dreaming.cpp:10:20: error: expected unqualified-id before '>>' token
   10 | vector<pair<int,int>> graph[sz];
      |                    ^~
dreaming.cpp:12:14: error: 'sz' was not declared in this scope
   12 | bool visited[sz];
      |              ^~
dreaming.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
dreaming.cpp:14:1: note: in expansion of macro 'int'
   14 | int sum=0;
      | ^~~
dreaming.cpp:14:5: error: 'sum' does not name a type
   14 | int sum=0;
      |     ^~~
dreaming.cpp:6:22: error: expected ')' before ';' token
    6 | #define int long long;
      |                      ^
dreaming.cpp:16:10: note: in expansion of macro 'int'
   16 | void dfs(int v)
      |          ^~~
dreaming.cpp:16:9: note: to match this '('
   16 | void dfs(int v)
      |         ^
dreaming.cpp:16:14: error: 'v' does not name a type
   16 | void dfs(int v)
      |              ^
dreaming.cpp:6:18: error: declaration does not declare anything [-fpermissive]
    6 | #define int long long;
      |                  ^~~~
dreaming.cpp:31:1: note: in expansion of macro 'int'
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      | ^~~
dreaming.cpp:6:22: error: expected ')' before ';' token
    6 | #define int long long;
      |                      ^
dreaming.cpp:31:16: note: in expansion of macro 'int'
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                ^~~
dreaming.cpp:31:15: note: to match this '('
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |               ^
dreaming.cpp:6:22: error: expected constructor, destructor, or type conversion before ';' token
    6 | #define int long long;
      |                      ^
dreaming.cpp:31:16: note: in expansion of macro 'int'
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                ^~~
dreaming.cpp:31:20: error: 'n' does not name a type
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                    ^
dreaming.cpp:31:26: error: 'm' does not name a type; did you mean 'tm'?
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                          ^
      |                          tm
dreaming.cpp:31:32: error: 'l' does not name a type
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                                ^
dreaming.cpp:31:38: error: 'a' does not name a type
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                                      ^
dreaming.cpp:31:46: error: 'b' does not name a type
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                                              ^
dreaming.cpp:31:54: error: 't' does not name a type; did you mean 'tm'?
   31 | int travelTime(int n,int m,int l,int a[],int b[],int t[])
      |                                                      ^
      |                                                      tm