Submission #811199

#TimeUsernameProblemLanguageResultExecution timeMemory
811199becaidoPaint By Numbers (IOI16_paint)C++17
32 / 100
1 ms308 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifndef WAIMAI #include "paint.h" #endif #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second /* r[i] = l[i] + c[i] r[i] < l[i + 1] 0 <= l[0] r[k - 1] <= n */ const int SIZE = 2e5 + 5; int n, k; int l[SIZE], r[SIZE]; int id[SIZE], d[SIZE]; string solve_puzzle(string s, vector<int> c) { n = s.size(); k = c.size(); FOR (i, 1, k - 1) l[i] = l[i - 1] + c[i - 1] + 1; r[k - 1] = n - c[k - 1]; for (int i = k - 2; i >= 0; i--) r[i] = r[i + 1] - 1 - c[i]; fill(id, id + n, -1); FOR (i, 0, k - 1) { d[l[i]]++; d[r[i] + c[i]]--; FOR (j, r[i], l[i] + c[i] - 1) id[j] = i; } FOR (i, 0, n - 1) { if (d[i] == 0) id[i] = k; d[i + 1] += d[i]; } FOR (i, 0, n - 1) { s[i] = (id[i] == k ? '_' : id[i] == -1 ? '?' : 'X'); } return s; } /* in1 .......... 2 3 4 out1 ??X???XX?? in2 ........ 2 3 4 out2 XXX_XXXX in3 ..._._.... 1 3 out3 ???___???? in4 .X........ 1 3 out4 ?XX?______ */ #ifdef WAIMAI const int S_MAX_LEN = 200 * 1000; char buf[S_MAX_LEN + 1]; int main() { assert(1 == scanf("%s", buf)); string s = buf; int c_len; assert(1 == scanf("%d", &c_len)); vector<int> c(c_len); for (int i = 0; i < c_len; i++) { assert(1 == scanf("%d", &c[i])); } string ans = solve_puzzle(s, c); printf("%s\n", ans.data()); return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...