QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#515715#4374. What Really Happened on Mars?karunaCompile Error//C++203.2kb2024-08-11 21:52:072024-08-11 21:52:08

Judging History

你现在查看的是最新测评结果

  • [2024-08-11 21:52:08]
  • 评测
  • [2024-08-11 21:52:07]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int SZ = 30;

int n, r, occ[SZ], rnk[SZ], pr[SZ], st[SZ], ans[SZ], has[SZ], sp[SZ];
vector<pii> C[SZ];
vector<int> G[SZ];

int vis[SZ], cur[SZ];
int dfs(int v) {
    vis[v] = true;
    int ret = cur[v];
    for (int x : G[v]) {
        if (!vis[x]) {
            ret = max(ret, dfs(x));
        }
    }
    return ret;
}
int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    cin >> n >> r;
    for (int i = 1; i <= n; i++) {
        cin >> st[i] >> pr[i];
        int sz;
        cin >> sz;
        for (int j = 0; j < sz; j++) {
            string S;
            cin >> S;
            char c = S[0];
            int num = stoi(S.substr(1));
            if (c == 'C') {
				while (num--) C[i].push_back({0, 1});
			}
            if (c == 'L') C[i].push_back({1, num});
            if (c == 'U') C[i].push_back({2, num});
        }
    }
    for (int i = 1; i <= n; i++) {
        for (auto [t, x] : C[i]) if (t == 1) rnk[x] = max(rnk[x], pr[i]);
    }
    int t = 0;
    while (true) {
        fill(cur, cur + n + 1, 0);
        int yes[n + 1]{};

		bool flag = false;
        for (int i = 1; i <= n; i++) {
			if (st[i] <= t && sp[i] < C[i].size()) yes[i] = true;
			if (sp[i] < C[i].size()) flag = true;
        }
		if (!flag) break;

        for (int i = 1; i <= n; i++) G[i].clear();
        for (int i = 1; i <= n; i++) if (yes[i]) {
            cur[i] = pr[i];
            if (C[i][sp[i]].ff == 1 && occ[C[i][sp[i]].ss]) {
                G[occ[C[i][sp[i]].ss]].push_back(i);
                yes[i] = false;
            }
        }

        for (int i = 1; i <= n; i++) {
            if (yes[i]) cur[i] = max(cur[i], dfs(i));
            fill(vis + 1, vis + 1 + n, 0);
        }

        int k = -1, elt;

        for (int i = 1; i <= r; i++) if (occ[i] && (k == -1 || rnk[i] > rnk[k])) {
            k = i;
            elt = occ[i];
        }

        if (k != -1) {
            int block[n + 1]{};
            int maxv = 0;
            for (int i = 1; i <= n; i++) if (yes[i] && C[i][sp[i]].ff == 1) {
                if (cur[i] <= rnk[k] && i != elt) {
                    block[i] = true;
                    maxv = max(maxv, cur[i]);
                }
            }

            for (int i = 1; i <= n; i++) if (yes[i] && !block[i]) {
                if (has[i]) cur[i] = max(cur[i], maxv);
            }
            for (int i = 1; i <= n; i++) if (block[i]) yes[i] = false;
        }

        int at = -1;
        for (int i = 1; i <= n; i++) if (yes[i] && (at == -1 || cur[at] < cur[i])) at = i;

		if (at == -1) {
			++t;
			continue;
		}
        auto [type, x] = C[at][sp[at]++];

        if (type == 0) {
            ans[at] = t + x;
            t += x;
        }
        else if (type == 1) {
            occ[x] = at;
            has[at]++;
        }
        else if (type == 2) {
            occ[x] = 0;
            has[at]--;
        }
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << '\n';
}

詳細信息

In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/gthr.h:148,
                 from /usr/include/c++/13/ext/atomicity.h:35,
                 from /usr/include/c++/13/bits/ios_base.h:39,
                 from /usr/include/c++/13/streambuf:43,
                 from /usr/include/c++/13/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/13/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:54,
                 from answer.code:3:
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  102 | __gthrw(pthread_once)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  103 | __gthrw(pthread_getspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  104 | __gthrw(pthread_setspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  106 | __gthrw(pthread_create)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  107 | __gthrw(pthread_join)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  108 | __gthrw(pthread_equal)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  109 | __gthrw(pthread_self)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  110 | __gthrw(pthread_detach)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  112 | __gthrw(pthread_cancel)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  114 | __gthrw(sched_yield)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  116 | __gthrw(pthread_mutex_lock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  117 | __gthrw(pthread_mutex_trylock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  119 | __gthrw(pthread_mutex_timedlock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:121:1: error: attribute value ‘t...