답안 #308326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308326 2020-09-30T22:59:28 Z Marlov Automobil (COCI17_automobil) C++14
0 / 100
24 ms 16128 KB
/*
Code by @marlov       
*/
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <iterator>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pi;
 
#define maxV 1000002
#define MOD 1000000007
 
struct mult{
	char c;
	long long x,m;
};
 
long long N,M,K;
long long sum=0;
long long row[maxV];
long long col[maxV];
mult arr[1000];
set<long long> rws;
set<long long> cls;
 
long long vRow(long long n){
	long long val=(M*((M*n+1)+(M*n+M)))/2;
	val%=MOD;
//	val+=M*n;
	return val%MOD;
}
long long vCol(long long n){
	long long val=(N*(n+1+n+1+M*(N-1)))/2;
	return val%MOD;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>N>>M>>K;
	fill(row,row+maxV,1);
	fill(col,col+maxV,1);
	for(long long i=0;i<K;i++){
		cin>>arr[i].c>>arr[i].x>>arr[i].m;
		arr[i].x--;
		if(arr[i].c=='R'){
			row[arr[i].x]*=arr[i].m;
			row[arr[i].x]%=MOD;
			rws.insert(arr[i].x);
		}else if(arr[i].c=='S'){
			col[arr[i].x]*=arr[i].m;
			col[arr[i].x]%=MOD;
			cls.insert(arr[i].x);
		}
	}
	for(long long cr:rws){
		for(long long cc:cls){
			long long cv=cr*M+cc+1;
			sum+=cv;
			sum-=row[cr]*cv;
			sum-=col[cc]*cv;
			sum%=MOD;
			//cout<<sum<<"\n";
			sum+=((row[cr]*col[cc])%MOD)*cv;
			sum%=MOD;
			//cout<<cv<<" creates "<<sum<<'\n';
		}
	}
	//for rows
	//cout<<sum<<'\n';
	for(long long i=0;i<N;i++){
		//cout<<vRow(i)<<'\n';
		sum+=(row[i])*vRow(i);
		//cout<<"row "<<i<<": "<<sum<<'\n';
		sum%=MOD;
	}
	//for col
	for(long long i=0;i<M;i++){
		//cout<<vCol(i)<<'\n';
		sum+=(col[i])*vCol(i);
		//cout<<"col "<<i<<": "<<sum<<'\n';
		sum%=MOD;
	}
	sum-=(((N*M)*(1+N*M))/2);
	cout<<sum<<'\n';
    return 0;
}
 
/* stuff you should look for
	* long long overflow, array bounds
	* special cases (n=1,n=0?)
	* do smth instead of nothing and stay organized
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 16000 KB Output isn't correct
2 Incorrect 12 ms 16000 KB Output isn't correct
3 Incorrect 10 ms 16128 KB Output isn't correct
4 Incorrect 10 ms 16000 KB Output isn't correct
5 Incorrect 10 ms 16000 KB Output isn't correct
6 Incorrect 10 ms 16000 KB Output isn't correct
7 Incorrect 11 ms 16000 KB Output isn't correct
8 Incorrect 10 ms 16000 KB Output isn't correct
9 Incorrect 11 ms 16000 KB Output isn't correct
10 Incorrect 11 ms 16000 KB Output isn't correct
11 Incorrect 12 ms 16000 KB Output isn't correct
12 Incorrect 19 ms 16000 KB Output isn't correct
13 Incorrect 11 ms 16000 KB Output isn't correct
14 Incorrect 15 ms 16000 KB Output isn't correct
15 Incorrect 18 ms 16000 KB Output isn't correct
16 Incorrect 24 ms 16000 KB Output isn't correct
17 Incorrect 24 ms 16000 KB Output isn't correct
18 Incorrect 24 ms 16000 KB Output isn't correct
19 Incorrect 24 ms 16000 KB Output isn't correct
20 Incorrect 24 ms 16000 KB Output isn't correct