CSES - Leirikisa 1 - Results
Submission details
Task:trener
Sender:Kuha
Submission time:2016-07-27 16:16:51 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.06 sdetails
#20.05 sdetails
#30.05 sdetails
#40.06 sdetails
#50.18 sdetails
#60.15 sdetails
#70.12 sdetails
#80.14 sdetails
#90.05 sdetails
#100.06 sdetails
#110.14 sdetails
#120.14 sdetails
#130.14 sdetails
#140.06 sdetails
#150.14 sdetails

Code

#include <bits/stdc++.h>
#define ll int//long long
#define INF 999999999
#define N (1<<17)
#define M 1000000007
#define C 5000

using namespace std;

ll ans = 0;
ll v[50][50];
ll m[50][50][C];
ll m2[50][50][C];
const inline ll sum (const ll x1, const ll x2, const ll y1, const ll y2) {
  ll s = v[y2][x2];
  if (x1) s -= v[y2][x1-1];
  if (y1) s -= v[y1-1][x2];
  if (x1 && y1) s += v[y1-1][x1-1];
  return ((s % C) + C) % C;
}

int main () {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  for (int y = 0; y < n; y++) {
    for (int x = 0; x <n; x++) {
      cin>>v[y][x];
      if (x) v[y][x] += v[y][x - 1];
    }
  }
  for(int y = 1; y < n; y++) {
    for (int x = 0; x < n; x++) {
     v[y][x] += v[y - 1][x]; 
    }
  }
  for (ll y = 0; y < n; y++) {
    for (ll x = 0; x <n; x++) {
      for (ll y1 = 0; y1 <= y; y1++) {
	for (ll x1 = 0; x1 <= x; x1++) {
	  ll s = sum(x1, x, y1, y);
	  m[y1][x1][s]++;
	  m2[y + 1][x1][s]++;
	}
      }
    }
  }
  for (ll y = 0; y < n; y++) {
    for (ll x = 0; x <n; x++) {
      for (ll y1 = 0; y1 <= y; y1++) {
	for (ll x1 = 0; x1 <= x; x1++) {
	  ll s = sum(x1, x, y1, y);
	  ans += m[y + 1][x + 1][s];
	  ans += m2[y1][x + 1][s];
	}
      }
    }
  }
  cout<<ans<<endl;
}

Test details

Test 1

Verdict:

input
18
babic
keksic
boric
bukic
...

correct output
bk

user output
1877922

Test 2

Verdict:

input
6
michael
jordan
lebron
james
...

correct output
PREDAJA

user output
2450

Test 3

Verdict:

input
10
wmyrsaney
raqdxrb
cnwkmtcokgskaxosctzyks
wlusaisfibbkwwzdqhezuj
...

correct output
w

user output
54450

Test 4

Verdict:

input
20
jgztazpytubijfsmjz
bokvgratzzdibku
qineboilzoqdqivc
bfctyltibtkbxq
...

correct output
b

user output
3537800

Test 5

Verdict:

input
50
wkrtpgfjmzlnqigogi
knqkkelytfjgmyxgyzcfd
xdkjrptlcuzwqgvrtzdbybh
vscbjbji
...

correct output
efv

user output
(empty)

Test 6

Verdict:

input
100
cmksprocpmkl
deyorcxeehlalonan
tdoqxhvygiwbbklj
rvamqpuprhynwduswppa
...

correct output
dfqrt

user output
(empty)

Test 7

Verdict:

input
130
assootmfjtgcagtxh
elqyysidg
otuxclnjhvxdadm
qmczmsgavvcboahqilzcuzm
...

correct output
abcdefghijklmnopqrstuvwxyz

user output
(empty)

Test 8

Verdict:

input
60
ljuolrxkieqkobvikuyvt
rhbrswllwycioayqjdertvb
xmzcubmbbed
uwgjslybqarciupgixt
...

correct output
eflmnr

user output
(empty)

Test 9

Verdict:

input
5
pnmdjqteyiapkhvebbqtwnnh
pirfyzgoqjsdsio
pkcltfhwxemgyubef
pxcjeh
...

correct output
p

user output
800

Test 10

Verdict:

input
20
fnuxegvwdqnkmkclmwlxeh
kmurkl
rlhxoacqadnzle
foxonevsx
...

correct output
PREDAJA

user output
3537800

Test 11

Verdict:

input
81
pidkcuqljmxi
mcpwm
zyyjrvkkkwkabwppvpm
aoighmgashjtvl
...

correct output
cegiptuwx

user output
(empty)

Test 12

Verdict:

input
100
evyottlutpqus
openmtwnmme
yvtgrk
shhpzhlgmpnnvswcpmjqiwe
...

correct output
PREDAJA

user output
(empty)

Test 13

Verdict:

input
99
yuqgzaqmnwrghzntlv
mcjkwfrkzchiauues
uclswdwkhtvkcsvklyhyiw
tggmfkr
...

correct output
abeklmnqtvz

user output
(empty)

Test 14

Verdict:

input
4
kzyulnmhnmkowhtgrqksru
xkgzlbwihowzdaodfg
nvxkdrltxviwyhkf
npvivwibxwrludfouga

correct output
PREDAJA

user output
200

Test 15

Verdict:

input
78
qdidvlkgpxjxmuqq
kgbugcncxazixwtxtww
abwtlqxkrusaocu
esjmgrutkzebklqt
...

correct output
ajlstxz

user output
(empty)