結果
| 問題 |
No.762 PDCAパス
|
| コンテスト | |
| ユーザー |
iicafiaxus
|
| 提出日時 | 2018-12-10 12:39:01 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,321 bytes |
| コンパイル時間 | 742 ms |
| コンパイル使用メモリ | 125,808 KB |
| 実行使用メモリ | 23,500 KB |
| 最終ジャッジ日時 | 2024-06-13 02:10:00 |
| 合計ジャッジ時間 | 6,866 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 TLE * 1 -- * 14 |
ソースコード
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
const long MOD = 1000000007;
class Node{
int id;
char value;
Node[] nodes;
this(int id){
this.id = id;
}
override string toString(){
return this.id.to!string ~ " " ~ this.value;
}
}
void main(){
int n = read.to!int;
Node[] nodes;
foreach(i; 0 .. n) nodes ~= new Node(i);
int m = read.to!int;
string s = readln.chomp;
foreach(i, c; s) nodes[i].value = c;
foreach(i; 0 .. m){
int u = read.to!int - 1, v = read.to!int - 1;
nodes[u].nodes ~= nodes[v];
nodes[v].nodes ~= nodes[u];
}
long temp1 = 0;
foreach(nd1; nodes){
if(nd1.value != 'P') continue;
long temp2 = 0;
foreach(nd2; nd1.nodes){
if(nd2.value != 'D') continue;
long temp3 = 0;
foreach(nd3; nd2.nodes){
if(nd3.value != 'C') continue;
long temp4 = 0;
foreach(nd4; nd3.nodes){
if(nd4.value != 'A') continue;
temp4 += 1;
temp4 %= MOD;
}
temp3 += temp4;
temp3 %= MOD;
}
temp2 += temp3;
temp2 %= MOD;
}
temp1 += temp2;
temp1 %= MOD;
}
auto ans = temp1;
ans.writeln;
}
iicafiaxus