제출 #1273430

#제출 시각아이디문제언어결과실행 시간메모리
1273430chanhchuong123Automobil (COCI17_automobil)C++20
65 / 100
1097 ms12096 KiB
#include<bits/stdc++.h>
using namespace std;

const bool multiTest = false;
#define task "C"
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define BIT(mask, i) ((mask) >> (i) & 1)

template<typename T1, typename T2> bool minimize(T1 &a, T2 b) {
	if (a > b) a = b; else return 0; return 1;
}
template<typename T1, typename T2> bool maximize(T1 &a, T2 b) {
	if (a < b) a = b; else return 0; return 1;
}

const int MOD = 1e9 + 7;
const int MAX = 1000100;
int n, m, k;
int row[MAX];
int col[MAX];
int sumCol[MAX];

void process(void) {
    cin >> n >> m >> k;

    for (int i = 1; i <= n; ++i) {
        row[i] = 1;
    }
    for (int j = 1; j <= m; ++j) {
        col[j] = 1;
        sumCol[j] = (1LL * j * n % MOD + (n - 1LL) * n / 2 % MOD * m) % MOD;
    }

    while (k--) {
        char type; int X, Y;
        cin >> type >> X >> Y;

        if (type == 'R') {
            for (int j = 1; j <= m; ++j) {
                sumCol[j] -= ((X - 1LL) * m + j) % MOD * row[X] % MOD;
                if (sumCol[j] < 0) sumCol[j] += MOD;
            }
            row[X] = 1LL * row[X] * Y % MOD;
            for (int j = 1; j <= m; ++j) {
                sumCol[j] = (sumCol[j] + ((X - 1LL) * m + j) % MOD * row[X] % MOD) % MOD;
            }
        } else {
            col[X] = 1LL * col[X] * Y % MOD;
        }
    }

    int ans = 0;
    for (int j = 1; j <= m; ++j) {
        ans = 1LL * (ans + 1LL * sumCol[j] * col[j] % MOD) % MOD;
    }
    cout << ans;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r",  stdin);
		freopen(task".out", "w", stdout);
	}

	int nTest = 1; if (multiTest) cin >> nTest;
	while (nTest--) {
		process();
	}

	return 0;
}

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

automobil.cpp: In function 'int main()':
automobil.cpp:66:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |                 freopen(task".inp", "r",  stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
automobil.cpp:67:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |                 freopen(task".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...