Submission #1355411

#TimeUsernameProblemLanguageResultExecution timeMemory
1355411otariusLost Array (NOI19_lostarray)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngl(chrono::steady_clock::now().time_since_epoch().count());

#define int long long
// #define int unsigned long long

// #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>

// const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll inf = 1e9;
const ll biginf = 1e18;
const int maxN = 1005;

void solve() {
    int n, m;
    cin >> n >> m;
    int arr[n + 1], a[m + 1], b[m + 1], c[m + 1];
    for (int i = 1; i <= m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        arr[a[i]] = max(arr[a[i]], c[i]);
        arr[b[i]] = max(arr[b[i]], c[i]);
    }

    for (int i = 1; i <= n; i++)
        cout << max(1, arr[i]) << ' ';
}
int32_t main() { 
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
        cout << '\n';
    }
    return 0;
}

Compilation message (stderr)

lostarray.cpp: In function 'void solve()':
lostarray.cpp:47:20: error: no matching function for call to 'max(int, long long int&)'
   47 |         cout << max(1, arr[i]) << ' ';
      |                 ~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from lostarray.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
lostarray.cpp:47:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |         cout << max(1, arr[i]) << ' ';
      |                 ~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
lostarray.cpp:47:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |         cout << max(1, arr[i]) << ' ';
      |                 ~~~^~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
lostarray.cpp:47:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |         cout << max(1, arr[i]) << ' ';
      |                 ~~~^~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
lostarray.cpp:47:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |         cout << max(1, arr[i]) << ' ';
      |                 ~~~^~~~~~~~~~~