답안 #382420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
382420 2021-03-27T10:03:18 Z talant117408 이상한 기계 (APIO19_strange_device) C++17
0 / 100
5000 ms 405740 KB
/*
    Code written by Talant I.D.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;

const int mod = 1e9+7;

ll mode(ll a) {
    a %= mod;
    if (a < 0) a += mod;
    return a;
}

ll subt(ll a, ll b) {
    return mode(mode(a)-mode(b));
}

ll add(ll a, ll b) {
    return mode(mode(a)+mode(b));
}

ll mult(ll a, ll b) {
    return mode(mode(a)*mode(b));
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b&1) res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

void usaco(string s) {
    freopen((s+".in").c_str(), "r", stdin);
    freopen((s+".out").c_str(), "w", stdout);
}

int main() {
    do_not_disturb
    //~ usaco("dirtraverse");
    
    int n;
    ll a, b, sum = 0;
    cin >> n >> a >> b;
    vector <pll> v(n), segs;
    for (auto &to : v) cin >> to.first >> to.second;
    for (auto to : v) sum += to.second-to.first+1;
    
    if (sum <= 1e6+7) {
        set <pll> st;
        for (auto to : v) {
            for (int j = to.first; j <= to.second; j++) {
                st.insert(mp((j+j/b)%a, j%b));
            }
        }
        cout << sz(st) << endl;
    }
    else if (b == 1) {
        
    }
    
    return 0;
}

Compilation message

strange_device.cpp: In function 'void usaco(std::string)':
strange_device.cpp:60:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   60 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:61:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   61 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 5103 ms 405740 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 5086 ms 60652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 403 ms 34668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 403 ms 34668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 403 ms 34668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 41 ms 5672 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 5103 ms 405740 KB Time limit exceeded
3 Halted 0 ms 0 KB -