답안 #1019520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019520 2024-07-11T02:40:37 Z NoLove Sails (IOI07_sails) C++14
5 / 100
1000 ms 4692 KB
/**
 *    author : Lăng Trọng Đạt
 *    created: 11-07-2024 
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;
int g[MAXN], cnt[MAXN], id[MAXN];
pii m[MAXN];
int n;

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    if (fopen("hi.inp", "r")) {
        freopen("hi.inp", "r", stdin);
//        freopen("hi.out", "w", stdout);
    } 

    cin >> n;
    // FOR(i, 1, 1e5) id[i] = i;
    int ans = 0;
    FOR(i, 1, n) {
        cin >> m[i].f >> m[i].se;
    }

    sort(m + 1, m + n + 1, [](pii& a, pii& b) -> bool {
        return a.f > b.f;
    });

    FOR(i, 1, n) {
        db(m[i])
        FOR(j, 1, m[i].f) id[j] = j;
        sort(id + 1, id + m[i].f + 1, [](int i, int j) {
            if (cnt[i] == cnt[j]) return i > j;
            return cnt[i] < cnt[j];
        });
        FOR(j, 1, m[i].f) db(j, id[j])
        FOR(j, 1, m[i].se) {
            db(j, id[j], cnt[id[j]])
            cnt[id[j]]++;
        }
    }
    FOR(i, 1, m[1].f) {
        db(i, cnt[i])
        ans = (ans + cnt[i] * (cnt[i] - 1) / 2) % MOD;
    }
    cout << ans;

}

Compilation message

sails.cpp: In function 'int32_t main()':
sails.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
sails.cpp:40:5: note: in expansion of macro 'FOR'
   40 |     FOR(i, 1, n) {
      |     ^~~
sails.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
sails.cpp:48:5: note: in expansion of macro 'FOR'
   48 |     FOR(i, 1, n) {
      |     ^~~
sails.cpp:18:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
sails.cpp:50:9: note: in expansion of macro 'FOR'
   50 |         FOR(j, 1, m[i].f) id[j] = j;
      |         ^~~
sails.cpp:18:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
sails.cpp:55:9: note: in expansion of macro 'FOR'
   55 |         FOR(j, 1, m[i].f) db(j, id[j])
      |         ^~~
sails.cpp:18:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
sails.cpp:56:9: note: in expansion of macro 'FOR'
   56 |         FOR(j, 1, m[i].se) {
      |         ^~~
sails.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
sails.cpp:61:5: note: in expansion of macro 'FOR'
   61 |     FOR(i, 1, m[1].f) {
      |     ^~~
sails.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen("hi.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 315 ms 568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1032 ms 1112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1026 ms 1624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 2396 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1035 ms 3920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 4444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1061 ms 4692 KB Time limit exceeded
2 Halted 0 ms 0 KB -