답안 #836018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836018 2023-08-24T05:03:11 Z definitelynotmee 웜뱃 (IOI13_wombats) C++17
컴파일 오류
0 ms 0 KB
#include "grader.c"
#include"wombats.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T>
using matrix = vector<vector<T>>;
const int INF = 1e9;

struct matriz{
    matrix<int> v;

    matriz(int n = 0, int val = INF){
        v = matrix<int>(n,vector<int>(n,val));
    }

    matriz operator*(matriz & other){
        const int n = v.size();
        matriz ret(n);
        
        auto solve =[&](int source, int l, int r, int optl, int optr, auto solve) -> void {
            if(r < l)
                return;
            
            int m = (l+r)>>1;

            int opt = optl;

            for (int i = optl+1; i <= optr; i++)
                opt = min(opt,i,[&](int a, int b){
                    return v[source][a]+other.v[a][m] < v[source][b]+other.v[b][m]; 
                });
            
            ret.v[source][m] = v[source][opt]+other.v[opt][m];
            
            solve(source,m+1,r,opt,optr,solve);
            solve(source,l,m-1,optl,opt,solve);
        };

        for(int i = 0; i < n; i++)
            solve(i,0,n-1,0,n-1,solve);
        

        // for(int i = 0; i < n; i++){
        //     for(int j = 0; j < n; j++){
        //         for(int k = 0; k < n; k++){
        //             ret.v[i][j] = min(v[i][k]+other.v[k][j], ret.v[i][j]);
        //         }
        //     }
        // }

        return ret;
    }
};

int n, m;

vector<matriz> inrow;
vector<matriz> nextrow;

matrix<int> hor;
matrix<int> ver;

void build_in_row(int linha){
    inrow[linha] = matriz(m,0);
    for(int j = 0; j < m; j++){
        int cur = 0;

        for(int k = j; k < m-1; k++){
            cur+=hor[linha][k];
            inrow[linha].v[j][k+1] = inrow[linha].v[k+1][j] = cur;
        }
    }
}

void build_next(int linha){
    matriz col(m);

    for(int i = 0; i < m; i++)
        col.v[i][i] = ver[linha][i];
    
    nextrow[linha] = inrow[linha]*col*
    inrow[linha+1];
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    // cerr << "ok" << endl;

    n = R;
    m = C;

    // cerr << n << ' ' << m << endl;
    hor = matrix<int>(n,vector<int>(m-1));
    ver = matrix<int>(n-1,vector<int>(m));
    // cerr << "ok" << endl;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m-1; j++)
            hor[i][j] = H[i][j];
    }

    for(int i = 0; i < n-1; i++){
        for(int j = 0; j < m; j++){
            ver[i][j] = V[i][j];
        }
    }

    inrow = vector<matriz>(n,matriz(m,0));

    // cerr << "ok" << endl;

    for(int i = 0; i < n; i++){
        // cerr << i << endl;
        build_in_row(i);
    }

    nextrow = vector<matriz>(n-1,matriz(m,0));

    for(int i = 0; i < n-1; i++){
        // cerr << i << endl;
        build_next(i);
    }

}

void changeH(int P, int Q, int W) {
    // cerr << P << ' ' << Q << endl;
    hor[P][Q] = W;
    build_in_row(P);
    if(P != n-1)
        build_next(P);
    if(P != 0)
        build_next(P-1);
}

void changeV(int P, int Q, int W) {
    // cerr << P << ' ' << Q << endl;
    ver[P][Q] = W;
    build_next(P);
}

int escape(int V1, int V2) {
    // cerr << V1 << ' ' << V2 << endl;

    matriz resp = nextrow[0];

    for(int i = 1; i < n-1; i++){
        resp = resp*nextrow[i];
    }

    return resp.v[V1][V2];

}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
In file included from wombats.cpp:1:
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
/usr/include/c++/10/bits/basic_ios.h: At global scope:
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
grader.c:8:4: error: expected unqualified-id before 'while'
    8 |  } while(0)
      |    ^~~~~
/usr/include/c++/10/bits/basic_ios.h: In member function 'std::basic_ios<_CharT, _Traits>::operator bool() const':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/ios:44,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/basic_ios.h:118:23: error: expected ';' before 'do'
  118 |       { return !this->fail(); }
      |                       ^
      |                       ;
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/basic_ios.h: In member function 'bool std::basic_ios<_CharT, _Traits>::operator!() const':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/ios:44,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/basic_ios.h:126:22: error: expected ';' before 'do'
  126 |       { return this->fail(); }
      |                      ^
      |                      ;
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/ostream.tcc: In member function 'std::basic_ostream<_CharT, _Traits>::pos_type std::basic_ostream<_CharT, _Traits>::tellp()':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/ostream:784,
                 from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/ostream.tcc:242:15: error: expected ')' before 'do'
  242 |    if (!this->fail())
      |       ~       ^
      |               )
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/ostream.tcc: In member function 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::seekp(std::basic_ostream<_CharT, _Traits>::pos_type)':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/ostream:784,
                 from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/ostream.tcc:263:15: error: expected ')' before 'do'
  263 |    if (!this->fail())
      |       ~       ^
      |               )
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/ostream.tcc: In member function 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::seekp(std::basic_ostream<_CharT, _Traits>::off_type, std::ios_base::seekdir)':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/ostream:784,
                 from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/ostream.tcc:295:15: error: expected ')' before 'do'
  295 |    if (!this->fail())
      |       ~       ^
      |               )
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/istream.tcc: In member function 'std::basic_istream<_CharT, _Traits>::pos_type std::basic_istream<_CharT, _Traits>::tellg()':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/istream:991,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/istream.tcc:835:19: error: expected ')' before 'do'
  835 |        if (!this->fail())
      |           ~       ^
      |                   )
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/istream.tcc: In member function 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::seekg(std::basic_istream<_CharT, _Traits>::pos_type)':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/istream:991,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/istream.tcc:865:19: error: expected ')' before 'do'
  865 |        if (!this->fail())
      |           ~       ^
      |                   )
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/istream.tcc: In member function 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::seekg(std::basic_istream<_CharT, _Traits>::off_type, std::ios_base::seekdir)':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/istream:991,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/istream.tcc:904:19: error: expected ')' before 'do'
  904 |        if (!this->fail())
      |           ~       ^
      |                   )
In file included from wombats.cpp:1:
/usr/include/c++/10/bits/regex.tcc: In member function 'int std::__cxx11::regex_traits< <template-parameter-1-1> >::value(_Ch_type, int) const':
grader.c:5:23: error: expected unqualified-id before 'do'
    5 | #define fail(s, x...) do { \
      |                       ^~
In file included from /usr/include/c++/10/bits/regex.h:2982,
                 from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from wombats.cpp:3:
/usr/include/c++/10/bits/regex.tcc:348:19: error: expected ';' before 'do'
  348 |       return __is.fail() ? -1 : __v;
      |                   ^
      |                   ;
/usr/include/c++/10/bits/regex.tcc:348:26: error: expected ';' before '?' token
  348 |       return __is.fail() ? -1 : __v;
      |                          ^
/usr/include/c++/10/bits/regex.tcc:348:26: error: expected primary-expression before '?' token