#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e6+5;
const string NAME = "";
int n,m,k,rs=0,row[MAXN],col[1005];
bool vis[MAXN];
vector<int> R,C;
inline void add(int& a, int b){
    a+=b;
    if(a>=MOD) a-=MOD;
}
inline void sub(int& a, int b){
    a-=b;
    if(a<0) a+=MOD;
}
int getsum(int l, int r, int dist){
    return 1ll*(l+r)*((r-l)/dist+1)/2%MOD;
}
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    cin >> n >> m >> k;
    fill(row+1,row+n+1,1);
    fill(col+1,col+m+1,1);
    for(int i = 1; i<=k; ++i){
        char type;
        int x,y;
        cin >> type >> x >> y;
        if(type=='R') row[x]=1ll*row[x]*y%MOD, R.pb(x);
        else col[x]=1ll*col[x]*y%MOD, C.pb(x), vis[x]=1;
    }
    sort(R.begin(),R.end());
    R.resize(unique(R.begin(),R.end())-R.begin());
    sort(C.begin(),C.end());
    C.resize(unique(C.begin(),C.end())-C.begin());
    for(int& x : R)
        add(rs,1ll*row[x]*getsum((x-1)*m+1,x*m,1)%MOD);
    for(int& x : C)
        add(rs,1ll*col[x]*getsum(x,x+(n-1)*m,m)%MOD);
    for(int& x : R)
        for(int& y : C){
            int val=(x-1)*m+y, mul=1ll*row[x]*col[y]%MOD;
            sub(rs,1ll*(row[x]+col[y])*val%MOD), add(rs,1ll*mul*val%MOD);
        }
    for(int i = 1; i<=m; ++i){
        if(vis[i]) continue;
        add(rs,getsum(i,i+(n-1)*m,m));
        for(int& j : R)
            sub(rs,(j-1)*m+i);
    }
    cout << rs;
}
컴파일 시 표준 에러 (stderr) 메시지
automobil.cpp: In function 'int main()':
automobil.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
automobil.cpp:39:45: note: in expansion of macro 'fo'
   39 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
automobil.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
automobil.cpp:39:45: note: in expansion of macro 'fo'
   39 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |