Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ASMx64-2018 Zemljiški kataster C++ 0/100Napačen odgovor (WA) 13. okt '18 @ 15:26

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,016 MiB 0,000 s OK
#2 0/10 3,188 MiB 0,001 s Napačen odgovor
Tvoj izhod:
​17
64
62
7
29
13
77
Pravilen izhod:
​17
64
64
7
32
13
77
#3 10/10 3,043 MiB 0,000 s OK
#4 10/10 3,191 MiB 0,000 s OK
#5 0/10 3,918 MiB 0,000 s Napačen odgovor
Tvoj izhod:
​5594
5472
389
5846
3841
Pravilen izhod:
​5887
5714
408
6145
4016
#6 0/10 6,887 MiB 0,322 s Napačen odgovor
Tvoj izhod:
​58818
74572
71523
79661
10052
Pravilen izhod:
​61681
78207
75052
83531
10522
#7 10/10 7,035 MiB 0,462 s OK
#8 10/10 6,887 MiB 0,310 s OK
#9 10/10 7,035 MiB 0,799 s OK
#10 10/10 7,035 MiB 0,000 s OK

Ocenjevani program (zadnjazmagovalna.cpp):
//#define DEBUG

#ifdef DEBUG
#include <fstream>
#else
#include <iostream>
#endif

#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstring>
using namespace std;

#ifdef DEBUG
ifstream cin("input");
ofstream cout("output");
#endif
#define SIZE 102
using namespace std;
int matrika[SIZE][10001];
int razlicni[10001];
int desni[10001];

int main() {
    int input, q, visina, sirina, x, y, res;

    cin >> visina >> sirina;
    for (int i = 0; i < visina; i++) {
        for (int j = 0; j < sirina; j++) cin >> matrika[i][j];
    }

    for (int i = 0; i < sirina; i++) {
        razlicni[i] = 1;
        for (int j = 1; j < visina; j++) {
            if (matrika[j][i] != matrika[j-1][i]) razlicni[i]++;
        }
    }

    for (int i = 0; i < sirina - 1; i++) {
        desni[i] = 0;
        for (int j = 0; j < visina; j++) {
            if (matrika[j][i] == matrika[j][i+1]) {
                if (j == 0) desni[i]++;
                else if (matrika[j-1][i] != matrika[j-1][i+1] || matrika[j-1][i] != matrika[j][i]) desni[i]++;
            }
            //cout << j << " " << desni[i] << endl;
        }
        //break;
        //return 0;
    }

    for (int i = 1; i < sirina; i++) razlicni[i] += razlicni[i-1];
    for (int i = 1; i < sirina; i++) desni[i] += desni[i-1];

    /*for (int i = 0; i < sirina; i++) cout << razlicni[i] << " ";
    cout << endl;
    for (int i = 0; i < sirina; i++) cout << desni[i] << " ";
    cout << endl;*/

    cin >> q;
    while (q--) {
        cin >> x >> y;
        x--; y--;
        res = 0;
        res = razlicni[y];
        //cout << res  << " ";
        if (x != 0) res -= razlicni[x-1];
        int temp = desni[y-1];
        if (x != 0) {
            temp -= desni[x - 1];
        }
        res -= temp;
        //cout << (res+temp) << " " << temp << " ";
        //cout << razlicni[2] << " " << razlicni[3] << desni[2] << " ";
        cout << res << endl;
    }

    return 0;
}