Submission #1046429

#TimeUsernameProblemLanguageResultExecution timeMemory
1046429dilanyanSprinklers (CEOI24_sprinklers)C++17
20 / 100
2011 ms1968 KiB
//-------------dilanyan------------\\ #define _CRT_SECURE_NO_WARNINGS #include<bits/stdc++.h> #include<stdio.h> using namespace std; //------------------Kargpefines--------------------\\ #define ll long long #define pb push_back #define all(u) (u).begin(), (u).end() #define pqueue priority_queue #define upper upper_bound #define lower lower_bound #define umap unordered_map #define uset unordered_set void KarginSet(string name = "") { ios_base::sync_with_stdio(false); cin.tie(NULL); if (name.size()) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } //-------------------KarginConstants------------------\\ const ll mod = 1e9 + 7; const ll inf = 2e9; //-------------------KarginCode-----------------------\\ const int N = 100005, M = 1000005; int n, m; int s[N], f[N]; void KarginSolve() { int n, m; cin >> n >> m; for (int i = 0;i < n;i++) cin >> s[i]; for (int i = 0;i < m;i++) cin >> f[i]; ll l = 0, r = 1e9, ans = -1, ans_mask; vector<int> vis(m, 0); while (l <= r) { ll mid = (l + r) / 2; bool flag = false; for (int mask = 0;mask < (1 << n);mask++) { fill(all(vis), 0); for (int i = 0; i < n;i++) { if (mask & (1 << i)) { int st = lower(f, f + m, s[i]) - f; int en = upper(f, f + m, s[i] + mid) - f; for (int i = st;i < en;i++) vis[i]++; } else { int st = lower(f, f + m, s[i] - mid) - f; int en = upper(f, f + m, s[i]) - f; for (int i = st;i < en;i++) vis[i]++; } } bool ok = true; for (int i = 0;i < m;i++) { if (vis[i] == 0) { ok = false; break; } } if (ok == true) { flag = true; ans_mask = mask; break; } } if (flag) { r = mid - 1; ans = mid; } else l = mid + 1; } if (ans == -1) cout << -1 << '\n'; else { cout << ans << '\n'; for (int i = 0; i < n;i++) { if (ans_mask & (1 << i))cout << 'R'; else cout << 'L'; } cout << '\n'; } } int main() { KarginSet(); int test = 1; //cin >> test; while (test--) { KarginSolve(); } return 0; };

Compilation message (stderr)

Main.cpp:1:1: warning: multi-line comment [-Wcomment]
    1 | //-------------dilanyan------------\\
      | ^
Main.cpp:8:1: warning: multi-line comment [-Wcomment]
    8 | //------------------Kargpefines--------------------\\
      | ^
Main.cpp:27:1: warning: multi-line comment [-Wcomment]
   27 | //-------------------KarginConstants------------------\\
      | ^
Main.cpp:32:1: warning: multi-line comment [-Wcomment]
   32 | //-------------------KarginCode-----------------------\\
      | ^
Main.cpp: In function 'void KarginSet(std::string)':
Main.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...