Submission #470606

#TimeUsernameProblemLanguageResultExecution timeMemory
470606nicolaalexandraTreasure (different grader from official contest) (CEOI13_treasure2)C++14
80 / 100
9 ms972 KiB
#include <bits/stdc++.h> #include "treasure.h" #define DIM 110 #define mp make_pair using namespace std; int a[DIM][DIM]; map <pair<pair<int,int>,pair<int,int> >, int > f; int n,i,j; void findTreasure (int n) { for (int i=1;i<=n/2;i++) for (int j=1;j<=n/2;j++){ if (f[mp(mp(i,j),mp(n,n))]) a[i][j] += f[mp(mp(i,j),mp(n,n))]; else { int val = countTreasure(i,j,n,n); a[i][j] += val; f[mp(mp(i,j),mp(n,n))] = val; } if (f[mp(mp(i,j+1),mp(n,n))]) a[i][j] -= f[mp(mp(i,j+1),mp(n,n))]; else { int val = countTreasure(i,j+1,n,n); a[i][j] -= val; f[mp(mp(i,j+1),mp(n,n))] = val; } if (f[mp(mp(i+1,j),mp(n,n))]) a[i][j] -= f[mp(mp(i+1,j),mp(n,n))]; else { int val = countTreasure(i+1,j,n,n); a[i][j] -= val; f[mp(mp(i+1,j),mp(n,n))] = val; } if (f[mp(mp(i+1,j+1),mp(n,n))]) a[i][j] += f[mp(mp(i+1,j+1),mp(n,n))]; else { int val = countTreasure(i+1,j+1,n,n); a[i][j] += val; f[mp(mp(i+1,j+1),mp(n,n))] = val; } } for (int i=1;i<=n/2;i++) for (int j=n/2+1;j<=n;j++){ if (f[mp(mp(i,1),mp(n,j))]) a[i][j] += f[mp(mp(i,1),mp(n,j))]; else { int val = countTreasure(i,1,n,j); a[i][j] += val; f[mp(mp(i,1),mp(n,j))] = val; } if (f[mp(mp(i,1),mp(n,j-1))]) a[i][j] -= f[mp(mp(i,1),mp(n,j-1))]; else { int val = countTreasure(i,1,n,j-1); a[i][j] -= val; f[mp(mp(i,1),mp(n,j-1))] = val; } if (f[mp(mp(i+1,1),mp(n,j))]) a[i][j] -= f[mp(mp(i+1,1),mp(n,j))]; else { int val = countTreasure(i+1,1,n,j); a[i][j] -= val; f[mp(mp(i+1,1),mp(n,j))] = val; } if (f[mp(mp(i+1,1),mp(n,j-1))]) a[i][j] += f[mp(mp(i+1,1),mp(n,j-1))]; else { int val = countTreasure(i+1,1,n,j-1); a[i][j] += val; f[mp(mp(i+1,1),mp(n,j-1))] = val; } } for (int i=n/2+1;i<=n;i++) for (int j=1;j<=n/2;j++){ if (f[mp(mp(1,j),mp(i,n))]) a[i][j] += f[mp(mp(1,j),mp(i,n))]; else { int val = countTreasure(1,j,i,n); a[i][j] += val; f[mp(mp(1,j),mp(i,n))] = val; } if (f[mp(mp(1,j),mp(i-1,n))]) a[i][j] -= f[mp(mp(1,j),mp(i-1,n))]; else { int val = countTreasure(1,j,i-1,n); a[i][j] -= val; f[mp(mp(1,j),mp(i-1,n))] = val; } if (f[mp(mp(1,j+1),mp(i,n))]) a[i][j] -= f[mp(mp(1,j+1),mp(i,n))]; else { int val = countTreasure(1,j+1,i,n); a[i][j] -= val; f[mp(mp(1,j+1),mp(i,n))] = val; } if (f[mp(mp(1,j+1),mp(i-1,n))]) a[i][j] += f[mp(mp(1,j+1),mp(i-1,n))]; else { int val = countTreasure(1,j+1,i-1,n); a[i][j] += val; f[mp(mp(1,j+1),mp(i-1,n))] = val; } } for (int i=n/2+1;i<=n;i++) for (int j=n/2+1;j<=n;j++){ if (f[mp(mp(1,1),mp(i,j))]) a[i][j] += f[mp(mp(1,1),mp(i,j))]; else { int val = countTreasure(1,1,i,j); a[i][j] += val; f[mp(mp(1,1),mp(i,j))] = val; } if (f[mp(mp(1,1),mp(i-1,j))]) a[i][j] -= f[mp(mp(1,1),mp(i-1,j))]; else { int val = countTreasure(1,1,i-1,j); a[i][j] -= val; f[mp(mp(1,1),mp(i-1,j))] = val; } if (f[mp(mp(1,1),mp(i,j-1))]) a[i][j] -= f[mp(mp(1,1),mp(i,j-1))]; else { int val = countTreasure(1,1,i,j-1); a[i][j] -= val; f[mp(mp(1,1),mp(i,j-1))] = val; } if (f[mp(mp(1,1),mp(i-1,j-1))]) a[i][j] += f[mp(mp(1,1),mp(i-1,j-1))]; else { int val = countTreasure(1,1,i-1,j-1); a[i][j] += val; f[mp(mp(1,1),mp(i-1,j-1))] = val; } } for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) if (a[i][j]) Report (i,j); }
#Verdict Execution timeMemoryGrader output
Fetching results...