제출 #203146

#제출 시각아이디문제언어결과실행 시간메모리
203146Mercenary이상한 기계 (APIO19_strange_device)C++14
5 / 100
535 ms17252 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 2e5 + 5; const int mod = 1e9 + 7; int n , A , B; const ll inf = 1e18 + 3; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n >> A >> B; ll d = __gcd(A,B+1);A /= d; if(A > inf / B)A = inf; else A *= B; vector<pair<ll,ll>> val; while(n--){ ll l ,r;cin >> l >> r; if(r - l + 1 >= A)tie(l,r) = mp(0,A-1); l %= A;r %= A; // cout << l << " " << r << endl; if(l <= r)val.pb(mp(l,r)); else val.pb(mp(0,r)),val.pb(mp(l,A-1)); } sort(val.begin(),val.end()); ll cur = 0 , res = 0; for(auto c : val){ if(cur <= c.second){ res += c.second - max(cur,c.first) + 1; } // cout << c.first << " " << c.second << " " << cur << " " << res << endl; cur = max(cur,c.second+1); } cout << res; }

컴파일 시 표준 에러 (stderr) 메시지

strange_device.cpp: In function 'int main()':
strange_device.cpp:32:24: warning: overflow in implicit constant conversion [-Woverflow]
     if(A > inf / B)A = inf;
                        ^~~
strange_device.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...