Submission #470570

# Submission time Handle Problem Language Result Execution time Memory
470570 2021-09-04T09:48:38 Z nicolaalexandra Treasure (different grader from official contest) (CEOI13_treasure2) C++14
46 / 100
1 ms 332 KB
#include <bits/stdc++.h>
#include "treasure.h"
#define DIM 110
using namespace std;

int a[DIM][DIM];
int n,i,j;

/*int countTreasure (int x, int y, int x2, int y2){
    cout<<x<<" "<<y<<" "<<x2<<" "<<y2<<endl;
    int ans;
    cin>>ans;
    return ans;
}
void Report (int i, int j){

}
*/
void solve (int x, int y, int x2, int y2, int cnt){

    if (x > x2 || y > y2 || !cnt)
        return;

    if (cnt == (x2-x+1) * (y2-y+1)){
        for (int i=x;i<=x2;i++)
            for (int j=y;j<=y2;j++)
                a[i][j] = 1;
        return;
    }

    int midx = (x+x2)>>1, midy = (y+y2)>>1, val1, val2, val3, val4;

    val1 = countTreasure (x,y,midx,midy);
    solve (x,y,midx,midy,val1);

    if (midy+1 <= y2){
        val2 = countTreasure (x,midy+1,midx,y2);
        solve (x,midy+1,midx,y2,val2);
    }
    if (midx+1 <= x2){
        val3 = countTreasure (midx+1,y,x2,midy);
        solve (midx+1,y,x2,midy,val3);
    }
    if (midx+1 <= x2 && midy+1 <= y2){
        val4 = cnt - val1 - val2 - val3;
        solve (midx+1,midy+1,x2,y2,val4);
    }

}

void findTreasure (int n) {

    solve (1,1,n,n,countTreasure(1,1,n,n));

    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            if (a[i][j])
                Report (i,j);

    /*cout<<"END\n";
    for (i=1;i<=n;i++,cout<<"\n")
        for (j=1;j<=n;j++)
            cout<<a[i][j];
*/
}

Compilation message

treasure.cpp: In function 'void solve(int, int, int, int, int)':
treasure.cpp:45:27: warning: 'val2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |         val4 = cnt - val1 - val2 - val3;
      |                ~~~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 204 KB Output is partially correct - N = 5, K = 574, score = 1
2 Partially correct 1 ms 204 KB Output is partially correct - N = 10, K = 8623, score = 1
3 Correct 1 ms 296 KB Output is correct - N = 15, K = 20064, score = 10
4 Correct 1 ms 204 KB Output is correct - N = 16, K = 21046, score = 10
5 Partially correct 1 ms 332 KB Output is partially correct - N = 55, K = 8450116, score = 1
6 Partially correct 1 ms 296 KB Output is partially correct - N = 66, K = 17512715, score = 1
7 Correct 1 ms 332 KB Output is correct - N = 77, K = 7505625, score = 10
8 Correct 1 ms 332 KB Output is correct - N = 88, K = 9818645, score = 10
9 Partially correct 1 ms 332 KB Output is partially correct - N = 99, K = 90441086, score = 1
10 Partially correct 1 ms 332 KB Output is partially correct - N = 100, K = 95317319, score = 1