Submission #991542

# Submission time Handle Problem Language Result Execution time Memory
991542 2024-06-02T11:56:00 Z amine_aroua Rectangles (IOI19_rect) C++17
Compilation error
0 ms 0 KB
#include <cstdio>
#include <unistd.h>
#include <cassert>
#include<bits/stdc++.h>
using namespace std;
#define Int long long
#define fore(i , n) for(int i = 0 ; i<n;i++)
#define forr(i , x , y) for(int i = x ; i<=y;i++)
#define pb push_back
#define forn(i , x , y) for(int i = x ; i >= y; i--)
class InputReader {
private:
    static const int SIZE = 4096;

    int inputFileDescriptor;
    char buf[SIZE];
    int curChar;
    int numChars;

public:

    inline InputReader(int _inputFileDescriptor):
            inputFileDescriptor(_inputFileDescriptor),
            curChar(0),
            numChars(0) {
    }

    inline void close() {
        ::close(inputFileDescriptor);
    }

    inline char read() {
        assert(numChars != -1);
        if (curChar >= numChars) {
            curChar = 0;
            numChars = ::read(inputFileDescriptor, buf, SIZE);
            if (numChars == -1)
                return -1;
        }
        return buf[curChar++];
    }

    inline int readInt() {
        int c = eatWhite();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            assert(c >= '0' && c <= '9');
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    inline string readString() {
        char c = eatWhite();
        string res;
        do {
            res += c;
            c = read();
        } while (!isSpaceChar(c));
        return res;
    }

    inline string readLine() {
        string res;
        while (true) {
            char c = read();
            if (c == '\n' || c == '\r' || c == -1)
                break;
            res += c;
        }
        return res;
    }

    inline char eatWhite() {
        char c = read();
        while (isSpaceChar(c))
            c = read();
        return c;
    }

    static inline bool isSpaceChar(char c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
};

long long count_rectangles(std::vector<std::vector<int> > a) {
    int n = (int)a.size();
    int m = (int)a[0].size();
    Int ans = 0;
    forr(i1 ,1 ,n - 1)
    {
        forr(j1 ,1, m - 2)
        {
            forr(i2 ,i1 , n - 2)
            {
                forr(j2 ,j1 ,  m - 2)
                {
                    bool acc = 1;
                    forr(i , i1 , i2)
                    {
                        forr(j , j1 , j2)
                        {
                            if(a[i][j] >= a[i][j1 - 1] || a[i][j] >= a[i][j2 + 1] || a[i][j] >= a[i1 - 1][j] || a[i][j] >= a[i2 + 1][j])
                            {
                                acc = 0;
                                break;
                            }
                        }
                        if(!acc)
                            break;
                    }
                    ans+=acc;
                }
            }
        }
    }
    return ans;
}
int main() {
    InputReader inputReader(STDIN_FILENO);
    int n, m;
    n = inputReader.readInt();
    m = inputReader.readInt();
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++)	{
        for (int j = 0; j < m; j++) {
            a[i][j] = inputReader.readInt();
        }
    }
    inputReader.close();

    long long result = count_rectangles(a);

    printf("%lld\n", result);
    fclose(stdout);
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/cc12ca09.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqtAQbb.o:rect.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status