제출 #403478

#제출 시각아이디문제언어결과실행 시간메모리
403478Hazem이상한 기계 (APIO19_strange_device)C++14
10 / 100
5076 ms524292 KiB
#include <bits/stdc++.h> using namespace std; #define LL long long #define F first #define S second #define pii pair<int,int> #define piii pair<pair<int,int>,int> const int N = 1e6+10; const int M = 200; const LL INF = 1e9; const LL LINF = 2e18; const LL MOD = 1e9+7; const double PI = 3.141592653589793; pair<LL,LL>p[N]; vector<pair<LL,LL>>vec; LL gcd(LL a,LL b){return !b?a:gcd(b,a%b);} int main(){ //freopen("out.txt","w",stdout); LL n,a,b,Len; scanf("%lld%lld%lld",&n,&a,&b); // for(int i=0;i<=n;i++) // printf("%d %d\n",(i+i/b)%a,i%b); LL g = gcd(a,b+1); a /= g; if(log(a)+log(b+1)>=log(LLONG_MAX)) Len = LINF; else Len = a*(b+1)-a; bool q = 0; set<LL>st; LL ans = 0; for(int i=1;i<=n;i++){ scanf("%lld%lld",&p[i].F,&p[i].S); q |= p[i].S-p[i].F+1>=Len; p[i].F %= Len;p[i].S %= Len; if(p[i].F<=p[i].S) //ans += p[i].S-p[i].F+1; for(int j=p[i].F;j<=p[i].S;j++) st.insert(j); else { //ans += Len-p[i].F; for(int j=p[i].F;j<=Len-1;j++) st.insert(j); for(int j=0;j<=p[i].S;j++) st.insert(j); //ans += p[i].S+1; } if(p[i].S>=p[i].F) vec.push_back({p[i].F,p[i].S}); else vec.push_back({p[i].F,Len-1}),vec.push_back({0,p[i].S}); } // sort(vec.begin(),vec.end()); // LL l = 0,r = -1,ans = 0; // vec.push_back({LINF,LINF}); // for(int i=0;i<vec.size();i++){ // if(vec[i].F>r) // ans += r-l+1,l = vec[i].F,r = vec[i].S; // else // r = vec[i].S; // } printf("%lld\n",q?Len:st.size()); }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:42:8: warning: unused variable 'ans' [-Wunused-variable]
   42 |     LL ans = 0;
      |        ^~~
strange_device.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%lld%lld%lld",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         scanf("%lld%lld",&p[i].F,&p[i].S);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...