結果
| 問題 |
No.440 2次元チワワ問題
|
| コンテスト | |
| ユーザー |
Lepton_s
|
| 提出日時 | 2016-10-28 23:46:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,882 bytes |
| コンパイル時間 | 785 ms |
| コンパイル使用メモリ | 85,860 KB |
| 実行使用メモリ | 814,668 KB |
| 最終ジャッジ日時 | 2024-11-24 06:37:09 |
| 合計ジャッジ時間 | 13,724 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 MLE * 15 |
ソースコード
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<25;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;
#define N 502
#define Q 100000
ll h, w;
vector<string> s(N), s2(N);
ll a[Q], b[Q], c[Q], d[Q];
ll q;
ll res[Q];
ll dp[N][N][N];
void rot(){
for(int i = 0; i < q; i++){
int t;
t = h-a[i]-1;
a[i] = b[i];
b[i] = t;
t = h-c[i]-1;
c[i] = d[i];
d[i] = t;
swap(b[i], d[i]);
}
for(int i = 0; i < N; i++) s2[i] = "";
for(int i = h-1; i >= 0; i--)
for(int j = 0; j < w; j++)
s2[j] += s[i][j];
swap(s, s2);
swap(h, w);
}
void solve(){
//memset(dp, 0, sizeof(dp));
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
dp[i][j][j] = 0;
int nc = 0, nw = 0;
for(int k = j; k < w; k++){
if(s[i][k]=='c'){
dp[i][j][k+1] = dp[i][j][k];
nc++;
} else {
dp[i][j][k+1] = dp[i][j][k]+nw;
nw += nc;
}
}
}
}
for(int l = 0; l < q; l++){
for(int i = a[l]; i <= c[l]; i++){
res[l] += dp[i][b[l]][d[l]+1];
}
}
}
int main(){
cin>>h>>w;
for(int i = 0; i < h; i++) cin>>s[i];
cin>>q;
for(int i = 0; i < q; i++){
cin>>a[i]>>b[i]>>c[i]>>d[i];
a[i]--; b[i]--; c[i]--; d[i]--;
}
for(int i = 0; i < 4; i++){
/*cerr<<h<<" "<<w<<endl;
for(int j = 0; j < h; j++){
cerr<<s[j]<<endl;
}
cerr<<q<<endl;
for(int j = 0; j < q; j++){
cerr<<a[j]<<" "<<b[j]<<" "<<c[j]<<" "<<d[j]<<endl;
}*/
rot();
solve();
}
for(int i = 0; i < q; i++) cout<<res[i]<<endl;
return 0;
}
Lepton_s