Submission #535317

# Submission time Handle Problem Language Result Execution time Memory
535317 2022-03-10T02:35:01 Z Koying Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
332 ms 304 KB
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast")
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define MEM(x, n) memset(x, n, sizeof(x))
#define pii pair<int, int>
#define pdd pair<double, double>
#define DB(x) cerr << #x << " " << x << endl;
#define endl "\n"
#define Koying ios::sync_with_stdio(0), cin.tie(0)
#define lowbit(x) x &(-x)
#define F first
#define S second
const int INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

#define MAXN 205

int n, l;
pii x[MAXN];

/*void sol1() {
    pii dp[1 << 15];
    MEM(dp, 0);
    for (int mask = 1; i < (n << 15); mask++) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt++;
            if (mask & (1 << i)) {
                int tarmask = mask - (1 << i);
                if (dp[tarmask].S + abs(x))
                    int owo;
            }
        }
    }
}*/

pii dp[MAXN][MAXN * MAXN];

int ans = 0;
bitset<MAXN> vis;
int cnt = 0;

void dfs(int i, int time, int depth) {
    vis[i] = true;
    cnt++;
    if (cnt > 1e7) {
        cout << n << endl;
        exit(0);
    }
    //cout << i << endl;
    cmax(ans, depth);
    for (int e = 1; e <= n; e++) {
        if (!vis[e] && time + min((x[i].S - x[e].S + l) % l, (x[e].S - x[i].S + l) % l) <= x[e].F) {
            dfs(e, time + min((x[i].S - x[e].S + l) % l, (x[e].S - x[i].S + l) % l), depth + 1);
        }
    }
    vis[i] = false;
}

void sol() {
    cin >> n >> l;
    for (int i = 1; i <= n; i++)
        cin >> x[i].S;
    for (int i = 1; i <= n; i++)
        cin >> x[i].F;
    /*if (n <= 15) {
        sol1();
        return;
    }*/
    sort(x, x + n);
    for (int i = 1; i <= n; i++) {
        if (min(x[i].S, l - x[i].S) <= x[i].F)
            dfs(i, min(x[i].S, l - x[i].S), 1);
    }
    cout << ans << endl;
}

signed main()
{
    Koying;
    int t = 1;
    //cin >> t;
    sol();
    return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:86:9: warning: unused variable 't' [-Wunused-variable]
   86 |     int t = 1;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 332 ms 304 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 332 ms 304 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 332 ms 304 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 332 ms 304 KB Output isn't correct
17 Halted 0 ms 0 KB -