Submission #951882

# Submission time Handle Problem Language Result Execution time Memory
951882 2024-03-22T21:43:43 Z hugsfromadicto Pohlepko (COCI16_pohlepko) C++14
0 / 80
37 ms 65536 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define all(a) a.begin(),a.end()
#define pb push_back
#define MAX(a,b,c) max(a,max(b,c))
using namespace std;
void USACO(string filename){
  freopen((filename+".in").c_str(),"r",stdin);
  freopen((filename+".out").c_str(),"w",stdout);
}
void fre()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

struct BIT
{
    int n;
    vector<int> ft;
    void init(int N)
    {
        n = N + 5;
        ft.assign(n + 5, 0);
    }
    void add(int pos, int val)
    {
        for (pos = pos + 1; pos <= n; pos += pos & -pos) ft[pos] += val;
    }
    int get(int pos, int res = 0)
    {
        for (pos = pos + 1; pos > 0; pos -= pos & -pos) res += ft[pos];
        return res;
    }
};
struct DSU
{
    int n;
    vector<int> e;
    void init(int N)
    {
        n = N;
        e.assign(n + 1, -1);
    }
    int get(int x)
    {
        if (e[x] < 0) return x;
        return e[x] = get(e[x]);
    }
    void unite(int x, int y)
    {
        x = get(x);
        y = get(y);
        if (x == y) return;
        if (e[x] > e[y]) swap(x, y);
        e[x] += e[y];
        e[y] = x;
    }
};

bool check(int n)
{
    while(n != 0)
    {
        if(n % 10 != 4 && n % 10 != 7)
            return false;
        n /= 10;
    }
    return true;
}
const int mxN = 2e3 + 15;
string a[mxN][mxN], dp[mxN][mxN];
void _()
{
    int n,m;
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        for(int j = 0; j < m; ++j)
        {
            a[i][j] = s[j];
        }
    }
    dp[0][0] = a[0][0];
    for(int i = 1; i < n; ++i)
        dp[i][0] = dp[i - 1][0] + a[i][0];
    for(int j = 1; j < m; ++j)
        dp[0][j] = dp[0][j - 1] + a[0][j];
    for(int i = 1; i < n; ++i)
    {
        for(int j = 1; j < m; ++j)
        {
            dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
        }
    }
    cout << dp[n - 1][m - 1];
}


main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int tc = 1;
    while(tc--)
        _();
}

Compilation message

pohlepko.cpp:107:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  107 | main()
      | ^~~~
pohlepko.cpp: In function 'void USACO(std::string)':
pohlepko.cpp:13:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   freopen((filename+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pohlepko.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   freopen((filename+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pohlepko.cpp: In function 'void fre()':
pohlepko.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
pohlepko.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 65536 KB Execution killed with signal 9
2 Runtime error 14 ms 65536 KB Execution killed with signal 9
3 Runtime error 37 ms 65536 KB Execution killed with signal 9
4 Runtime error 18 ms 65536 KB Execution killed with signal 9
5 Runtime error 15 ms 65536 KB Execution killed with signal 9
6 Runtime error 28 ms 65536 KB Execution killed with signal 9
7 Runtime error 14 ms 65536 KB Execution killed with signal 9
8 Runtime error 30 ms 65536 KB Execution killed with signal 9
9 Runtime error 14 ms 65536 KB Execution killed with signal 9
10 Runtime error 16 ms 65536 KB Execution killed with signal 9
11 Runtime error 16 ms 65536 KB Execution killed with signal 9
12 Runtime error 15 ms 65536 KB Execution killed with signal 9
13 Runtime error 28 ms 65536 KB Execution killed with signal 9
14 Runtime error 16 ms 65536 KB Execution killed with signal 9
15 Runtime error 14 ms 65536 KB Execution killed with signal 9
16 Runtime error 15 ms 65536 KB Execution killed with signal 9