답안 #211462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211462 2020-03-20T12:11:17 Z VEGAnn 이상한 기계 (APIO19_strange_device) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ft first
#define sd second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define pll pair<ll, ll>
#define MP make_pair
#define PB push_back
using namespace std;
//typedef long long ll;
typedef long long __int128;
vector<pll> vc;
vector<pll> seg;
int n;
ll A, B;

int main(){

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#else
    ios_base::sync_with_stdio(0); cin.tie(0);
#endif // _LOCAL

    cin >> n >> A >> B;

//    if (B <= ll(1e6)){

        ll fi = A * B;

        while (fi % 2 == 0){

            fi >>= 1;
            if ((fi + fi / B) % A != 0 || fi % B != 0) {
                fi <<= 1;
                break;
            }
        }

        seg.clear();

        for (int i = 0; i < n; i++){
            ll l, r; cin >> l >> r;

            if (r - l + 1 >= fi){
                seg.PB(MP(0, fi - 1));
                continue;
            }

            ll vl = ((l - 1) / fi) * fi + fi;

            if (vl > r){
                vl -= fi;
                seg.PB(MP(l - vl, r - vl));
            } else {
                vl -= fi;
                seg.PB(MP(l - vl, fi - 1));
                vl += fi;
                seg.PB(MP(0ll, r - vl));
            }
        }

        sort(all(seg));

        ll lst = -1, ans = 0;

        for (pll cr : seg)
            if (cr.ft > lst){
                ans += cr.sd - cr.ft + 1ll;
                lst = cr.sd;
            } else {

                ans += max(lst, cr.sd) - lst;
                lst = max(lst, cr.sd);
            }

        cout << ans << '\n';

        return 0;
//    }
//
//    for (int i = 0; i < n; i++){
//        ll l, r; cin >> l >> r;
//
//        for (ll t = l; t <= r; t++)
//            vc.PB(MP((t + t / B) % A, t % B));
//    }
//
//    sort(all(vc));
//    vc.resize(unique(all(vc)) - vc.begin());
//
//    cout << sz(vc);

    return 0;
}

Compilation message

strange_device.cpp:11:19: error: declaration does not declare anything [-fpermissive]
 typedef long long __int128;
                   ^~~~~~~~
strange_device.cpp:6:18: error: 'll' was not declared in this scope
 #define pll pair<ll, ll>
                  ^
strange_device.cpp:12:8: note: in expansion of macro 'pll'
 vector<pll> vc;
        ^~~
strange_device.cpp:6:18: note: suggested alternative: 'all'
 #define pll pair<ll, ll>
                  ^
strange_device.cpp:12:8: note: in expansion of macro 'pll'
 vector<pll> vc;
        ^~~
strange_device.cpp:6:22: error: 'll' was not declared in this scope
 #define pll pair<ll, ll>
                      ^
strange_device.cpp:12:8: note: in expansion of macro 'pll'
 vector<pll> vc;
        ^~~
strange_device.cpp:6:22: note: suggested alternative: 'all'
 #define pll pair<ll, ll>
                      ^
strange_device.cpp:12:8: note: in expansion of macro 'pll'
 vector<pll> vc;
        ^~~
strange_device.cpp:6:24: error: template argument 1 is invalid
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:12:8: note: in expansion of macro 'pll'
 vector<pll> vc;
        ^~~
strange_device.cpp:6:24: error: template argument 2 is invalid
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:12:8: note: in expansion of macro 'pll'
 vector<pll> vc;
        ^~~
strange_device.cpp:12:11: error: template argument 1 is invalid
 vector<pll> vc;
           ^
strange_device.cpp:12:11: error: template argument 2 is invalid
strange_device.cpp:6:18: error: 'll' was not declared in this scope
 #define pll pair<ll, ll>
                  ^
strange_device.cpp:13:8: note: in expansion of macro 'pll'
 vector<pll> seg;
        ^~~
strange_device.cpp:6:18: note: suggested alternative: 'all'
 #define pll pair<ll, ll>
                  ^
strange_device.cpp:13:8: note: in expansion of macro 'pll'
 vector<pll> seg;
        ^~~
strange_device.cpp:6:22: error: 'll' was not declared in this scope
 #define pll pair<ll, ll>
                      ^
strange_device.cpp:13:8: note: in expansion of macro 'pll'
 vector<pll> seg;
        ^~~
strange_device.cpp:6:22: note: suggested alternative: 'all'
 #define pll pair<ll, ll>
                      ^
strange_device.cpp:13:8: note: in expansion of macro 'pll'
 vector<pll> seg;
        ^~~
strange_device.cpp:6:24: error: template argument 1 is invalid
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:13:8: note: in expansion of macro 'pll'
 vector<pll> seg;
        ^~~
strange_device.cpp:6:24: error: template argument 2 is invalid
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:13:8: note: in expansion of macro 'pll'
 vector<pll> seg;
        ^~~
strange_device.cpp:13:11: error: template argument 1 is invalid
 vector<pll> seg;
           ^
strange_device.cpp:13:11: error: template argument 2 is invalid
strange_device.cpp:15:1: error: 'll' does not name a type; did you mean 'all'?
 ll A, B;
 ^~
 all
strange_device.cpp: In function 'int main()':
strange_device.cpp:25:17: error: 'A' was not declared in this scope
     cin >> n >> A >> B;
                 ^
strange_device.cpp:25:22: error: 'B' was not declared in this scope
     cin >> n >> A >> B;
                      ^
strange_device.cpp:29:9: error: 'll' was not declared in this scope
         ll fi = A * B;
         ^~
strange_device.cpp:29:9: note: suggested alternative: 'all'
         ll fi = A * B;
         ^~
         all
strange_device.cpp:31:16: error: 'fi' was not declared in this scope
         while (fi % 2 == 0){
                ^~
strange_device.cpp:31:16: note: suggested alternative: 'ft'
         while (fi % 2 == 0){
                ^~
                ft
strange_device.cpp:40:13: error: request for member 'clear' in 'seg', which is of non-class type 'int'
         seg.clear();
             ^~~~~
strange_device.cpp:43:16: error: expected ';' before 'l'
             ll l, r; cin >> l >> r;
                ^
strange_device.cpp:43:29: error: 'l' was not declared in this scope
             ll l, r; cin >> l >> r;
                             ^
strange_device.cpp:43:34: error: 'r' was not declared in this scope
             ll l, r; cin >> l >> r;
                                  ^
strange_device.cpp:45:30: error: 'fi' was not declared in this scope
             if (r - l + 1 >= fi){
                              ^~
strange_device.cpp:45:30: note: suggested alternative: 'i'
             if (r - l + 1 >= fi){
                              ^~
                              i
strange_device.cpp:8:12: error: request for member 'push_back' in 'seg', which is of non-class type 'int'
 #define PB push_back
            ^
strange_device.cpp:46:21: note: in expansion of macro 'PB'
                 seg.PB(MP(0, fi - 1));
                     ^~
strange_device.cpp:50:16: error: expected ';' before 'vl'
             ll vl = ((l - 1) / fi) * fi + fi;
                ^~
strange_device.cpp:52:17: error: 'vl' was not declared in this scope
             if (vl > r){
                 ^~
strange_device.cpp:52:17: note: suggested alternative: 'vc'
             if (vl > r){
                 ^~
                 vc
strange_device.cpp:53:23: error: 'fi' was not declared in this scope
                 vl -= fi;
                       ^~
strange_device.cpp:53:23: note: suggested alternative: 'i'
                 vl -= fi;
                       ^~
                       i
strange_device.cpp:8:12: error: request for member 'push_back' in 'seg', which is of non-class type 'int'
 #define PB push_back
            ^
strange_device.cpp:54:21: note: in expansion of macro 'PB'
                 seg.PB(MP(l - vl, r - vl));
                     ^~
strange_device.cpp:56:23: error: 'fi' was not declared in this scope
                 vl -= fi;
                       ^~
strange_device.cpp:56:23: note: suggested alternative: 'i'
                 vl -= fi;
                       ^~
                       i
strange_device.cpp:8:12: error: request for member 'push_back' in 'seg', which is of non-class type 'int'
 #define PB push_back
            ^
strange_device.cpp:57:21: note: in expansion of macro 'PB'
                 seg.PB(MP(l - vl, fi - 1));
                     ^~
strange_device.cpp:8:12: error: request for member 'push_back' in 'seg', which is of non-class type 'int'
 #define PB push_back
            ^
strange_device.cpp:59:21: note: in expansion of macro 'PB'
                 seg.PB(MP(0ll, r - vl));
                     ^~
strange_device.cpp:4:18: error: request for member 'begin' in 'seg', which is of non-class type 'int'
 #define all(x) x.begin(),x.end()
                  ^
strange_device.cpp:63:14: note: in expansion of macro 'all'
         sort(all(seg));
              ^~~
strange_device.cpp:4:28: error: request for member 'end' in 'seg', which is of non-class type 'int'
 #define all(x) x.begin(),x.end()
                            ^
strange_device.cpp:63:14: note: in expansion of macro 'all'
         sort(all(seg));
              ^~~
strange_device.cpp:65:12: error: expected ';' before 'lst'
         ll lst = -1, ans = 0;
            ^~~
strange_device.cpp:6:24: error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:67:14: note: in expansion of macro 'pll'
         for (pll cr : seg)
              ^~~
strange_device.cpp:6:24: note:   expected a type, got 'll'
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:67:14: note: in expansion of macro 'pll'
         for (pll cr : seg)
              ^~~
strange_device.cpp:6:24: error: type/value mismatch at argument 2 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:67:14: note: in expansion of macro 'pll'
         for (pll cr : seg)
              ^~~
strange_device.cpp:6:24: note:   expected a type, got 'll'
 #define pll pair<ll, ll>
                        ^
strange_device.cpp:67:14: note: in expansion of macro 'pll'
         for (pll cr : seg)
              ^~~
strange_device.cpp:67:23: error: 'begin' was not declared in this scope
         for (pll cr : seg)
                       ^~~
strange_device.cpp:67:23: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from strange_device.cpp:1:
/usr/include/c++/7/valarray:1211:5: note:   'std::begin'
     begin(const valarray<_Tp>& __va)
     ^~~~~
/usr/include/c++/7/valarray:1211:5: note:   'std::begin'
strange_device.cpp:67:23: error: 'end' was not declared in this scope
         for (pll cr : seg)
                       ^~~
strange_device.cpp:67:23: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from strange_device.cpp:1:
/usr/include/c++/7/valarray:1231:5: note:   'std::end'
     end(const valarray<_Tp>& __va)
     ^~~
/usr/include/c++/7/valarray:1231:5: note:   'std::end'
strange_device.cpp:2:12: error: request for member 'first' in 'cr', which is of non-class type 'int'
 #define ft first
            ^
strange_device.cpp:68:20: note: in expansion of macro 'ft'
             if (cr.ft > lst){
                    ^~
strange_device.cpp:68:25: error: 'lst' was not declared in this scope
             if (cr.ft > lst){
                         ^~~
strange_device.cpp:69:17: error: 'ans' was not declared in this scope
                 ans += cr.sd - cr.ft + 1ll;
                 ^~~
strange_device.cpp:69:17: note: suggested alternative: 'abs'
                 ans += cr.sd - cr.ft + 1ll;
                 ^~~
                 abs
strange_device.cpp:3:12: error: request for member 'second' in 'cr', which is of non-class type 'int'
 #define sd second
            ^
strange_device.cpp:69:27: note: in expansion of macro 'sd'
                 ans += cr.sd - cr.ft + 1ll;
                           ^~
strange_device.cpp:2:12: error: request for member 'first' in 'cr', which is of non-class type 'int'
 #define ft first
            ^
strange_device.cpp:69:35: note: in expansion of macro 'ft'
                 ans += cr.sd - cr.ft + 1ll;
                                   ^~
strange_device.cpp:3:12: error: request for member 'second' in 'cr', which is of non-class type 'int'
 #define sd second
            ^
strange_device.cpp:70:26: note: in expansion of macro 'sd'
                 lst = cr.sd;
                          ^~
strange_device.cpp:73:17: error: 'ans' was not declared in this scope
                 ans += max(lst, cr.sd) - lst;
                 ^~~
strange_device.cpp:73:17: note: suggested alternative: 'abs'
                 ans += max(lst, cr.sd) - lst;
                 ^~~
                 abs
strange_device.cpp:3:12: error: request for member 'second' in 'cr', which is of non-class type 'int'
 #define sd second
            ^
strange_device.cpp:73:36: note: in expansion of macro 'sd'
                 ans += max(lst, cr.sd) - lst;
                                    ^~
strange_device.cpp:3:12: error: request for member 'second' in 'cr', which is of non-class type 'int'
 #define sd second
            ^
strange_device.cpp:74:35: note: in expansion of macro 'sd'
                 lst = max(lst, cr.sd);
                                   ^~
strange_device.cpp:77:17: error: 'ans' was not declared in this scope
         cout << ans << '\n';
                 ^~~
strange_device.cpp:77:17: note: suggested alternative: 'abs'
         cout << ans << '\n';
                 ^~~
                 abs