제출 #203147

#제출 시각아이디문제언어결과실행 시간메모리
203147MercenaryStrange Device (APIO19_strange_device)C++14
컴파일 에러
0 ms0 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; ll A , B; const ll inf = (ll)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; } #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; ll A , B; const ll inf = (ll)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:73:11: error: redefinition of 'const int maxn'
 const int maxn = 2e5 + 5;
           ^~~~
strange_device.cpp:17:11: note: 'const int maxn' previously defined here
 const int maxn = 2e5 + 5;
           ^~~~
strange_device.cpp:74:11: error: redefinition of 'const int mod'
 const int mod = 1e9 + 7;
           ^~~
strange_device.cpp:18:11: note: 'const int mod' previously defined here
 const int mod = 1e9 + 7;
           ^~~
strange_device.cpp:75:5: error: redefinition of 'int n'
 int n;
     ^
strange_device.cpp:19:5: note: 'int n' previously declared here
 int n;
     ^
strange_device.cpp:76:4: error: redefinition of 'll A'
 ll A , B;
    ^
strange_device.cpp:20:4: note: 'll A' previously declared here
 ll A , B;
    ^
strange_device.cpp:76:8: error: redefinition of 'll B'
 ll A , B;
        ^
strange_device.cpp:20:8: note: 'll B' previously declared here
 ll A , B;
        ^
strange_device.cpp:77:10: error: redefinition of 'const ll inf'
 const ll inf = (ll)1e18 + 3;
          ^~~
strange_device.cpp:21:10: note: 'const ll inf' previously defined here
 const ll inf = (ll)1e18 + 3;
          ^~~
strange_device.cpp: In function 'int main()':
strange_device.cpp:79:5: error: redefinition of 'int main()'
 int main()
     ^~~~
strange_device.cpp:23:5: note: 'int main()' previously defined here
 int main()
     ^~~~
strange_device.cpp: In function 'int main()':
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".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:29: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);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp: In function 'int main()':
strange_device.cpp:84: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:85: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);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~