Submission #308328

# Submission time Handle Problem Language Result Execution time Memory
308328 2020-09-30T23:02:07 Z Marlov Automobil (COCI17_automobil) C++14
0 / 100
18 ms 16000 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);
		}
	}
	sum-=(((N*M)*(1+N*M))/2);
	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;
			//cout<<sum<<"\n";
			sum+=((row[cr]*col[cc]))*cv;
			//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';
	}
	//for col
	for(long long i=0;i<M;i++){
		//cout<<vCol(i)<<'\n';
		sum+=(col[i])*vCol(i);
		//cout<<"col "<<i<<": "<<sum<<'\n';
	}
	cout<<sum%MOD<<'\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
*/
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 16000 KB Output isn't correct
2 Incorrect 10 ms 16000 KB Output isn't correct
3 Incorrect 11 ms 16000 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 11 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 10 ms 16000 KB Output isn't correct
10 Incorrect 11 ms 16000 KB Output isn't correct
11 Incorrect 11 ms 16000 KB Output isn't correct
12 Incorrect 15 ms 16000 KB Output isn't correct
13 Incorrect 10 ms 16000 KB Output isn't correct
14 Incorrect 12 ms 16000 KB Output isn't correct
15 Incorrect 14 ms 15988 KB Output isn't correct
16 Incorrect 18 ms 16000 KB Output isn't correct
17 Incorrect 18 ms 16000 KB Output isn't correct
18 Incorrect 18 ms 16000 KB Output isn't correct
19 Incorrect 17 ms 16000 KB Output isn't correct
20 Incorrect 17 ms 16000 KB Output isn't correct