Submission #1090690

#TimeUsernameProblemLanguageResultExecution timeMemory
1090690BigBadBullyFire (BOI24_fire)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define int long long #define pii pair<int, int> #define ff first #define ss second using namespace std; const int inf = 1e17; const int mod = 998244353; int solve2(int n,int m,vector<pii> v) { for (int i = 0; i< n; i++) { while(v[i].ff>v[i].ss) v[i].ss+=m; } sort(v.begin(),v.end()); { vector<bool> del(n); int maxi = 0; for (int i = 0; i < n;i ++) { if (v[i].ss <= maxi) del[i] = 1; maxi = max(maxi,v[i].ss); } vector<pii> neu; for (int i = 0; i < n; i++) if (!del[i]) neu.push_back(v[i]); n = neu.size(); v = neu; } { vector<bool> del(n); int mini = v[n-1].ss; for (int i = n-1; i >= 0;i--) { if (v[i].ff >= mini) del[i] = 1; mini = min(mini,v[i].ff); } vector<pii> neu; for (int i = 0; i < n; i++) if (!del[i]) neu.push_back(v[i]); n = neu.size(); v = neu; } for (int i = 0; i< n;i++) v[i].ss%=m; /*for (int i = 0; i < n; i++) cout << v[i].ff << ' ' << v[i].ss << '\n';*/ int prev = v[0].ss; int used = 1; if (v[0].ff != 0) { cout << -1 << '\n'; return; } for (int i = 1; i < n; i++) { if (v[i].ff > prev) { used++; prev = v[i-1].ss; if (v[i].ff > prev) { cout << -1 << '\n'; return; } } if (prev != 0 && v[i].ss == 0) { used++; prev = inf; break; } } if(prev == inf) cout << used << '\n'; else cout << -1 << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,m; cin >> n >> m; vector<pii> v(n); for (int i = 0; i < n; i++) cin >> v[i].ff >> v[i].ss; cout << solve2(n,m,v) << endl; }

Compilation message (stderr)

Main.cpp: In function 'long long int solve2(long long int, long long int, std::vector<std::pair<long long int, long long int> >)':
Main.cpp:63:9: error: return-statement with no value, in function returning 'long long int' [-fpermissive]
   63 |         return;
      |         ^~~~~~
Main.cpp:74:17: error: return-statement with no value, in function returning 'long long int' [-fpermissive]
   74 |                 return;
      |                 ^~~~~~
Main.cpp:88:1: warning: control reaches end of non-void function [-Wreturn-type]
   88 | }
      | ^