답안 #588408

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
588408 2022-07-03T09:09:59 Z Killer2501 Vođe (COCI17_vode) C++14
120 / 120
1117 ms 193004 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "deleg"
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define fi first
#define se second
#define ull unsigned long long
using namespace std;
const ll mod = 1e15 + 7;
const ll N = 5e3 + 5;
const ll M = 1e6 + 5;
vector<ll> adj[N], sub[N];
vector<ll> kq;
int n, m, t, k, b[N], a[N], sum[N][N], dp[N][N];
string s[N];
pll p[N];
bool get1(int i, int l, int r)
{
    return (sum[i][l] - sum[i][r+1] > 0); 
}
bool get0(int i, int l, int r)
{
    return (sum[i][l] - sum[i][r+1] < k);
}
void sol()
{
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        dp[i][m-1] = 0;
        sum[i][m-1] = 0;
    }
    for(int j = m-2; j >= 0; j --)
    {
        for(int i = 1; i <= n; i ++)
        {
            int nxt = (i == n ? 1 : i+1);
            if(a[i] == a[nxt])
                dp[i][j] = get1(nxt, j+1, min(j+k, m-1));
            else 
                dp[i][j] = get0(nxt, j+1, min(j+k, m-1));
        }
        for(int i = 1; i <= n; i ++)sum[i][j] = sum[i][j+1]+dp[i][j];
    }
    for(int i = 1; i <= n; i ++)cout << (a[i]^dp[i][0]^1) <<" ";
}
int main()
{
    if (fopen(task ".in", "r"))
    {
        freopen(task ".in", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest = 1;
    // cin >> ntest;
    while (ntest-- > 0)
        sol();
}

Compilation message

vode.cpp: In function 'int main()':
vode.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(task ".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
vode.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 736 KB Output is correct
2 Correct 1 ms 1380 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 1628 KB Output is correct
3 Correct 2 ms 2664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3028 KB Output is correct
2 Correct 2 ms 2900 KB Output is correct
3 Correct 2 ms 3156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 4 ms 4820 KB Output is correct
3 Correct 4 ms 4660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6100 KB Output is correct
2 Correct 4 ms 5728 KB Output is correct
3 Correct 4 ms 5348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5460 KB Output is correct
2 Correct 4 ms 5588 KB Output is correct
3 Correct 1 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 38352 KB Output is correct
2 Correct 157 ms 41560 KB Output is correct
3 Correct 906 ms 189416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 296 ms 76640 KB Output is correct
2 Correct 832 ms 189012 KB Output is correct
3 Correct 336 ms 82248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1052 ms 190604 KB Output is correct
2 Correct 4 ms 5204 KB Output is correct
3 Correct 3 ms 3300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1027 ms 192096 KB Output is correct
2 Correct 805 ms 192608 KB Output is correct
3 Correct 1117 ms 193004 KB Output is correct