Submission #1069980

# Submission time Handle Problem Language Result Execution time Memory
1069980 2024-08-22T10:48:43 Z vjudge1 Sprinklers (CEOI24_sprinklers) C++17
3 / 100
10 ms 1236 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

void solve() {
   int n, m;
   cin >> n >> m;
   int s[n], f[m];
   for(int i=0; i<n; ++i) cin >> s[i];
   for(int i=0; i<m; ++i) cin >> f[i];
   if(n == 1) {
        if(f[0] < s[0] && f[m-1] > s[0]) {
            cout << -1 << endl;
            return;
        }
        cout << max(abs(f[0]-s[0]), abs(f[m-1]-s[0])) << endl;
        if(f[0] < s[0]) cout << "L" << endl;
        else cout << "R" << endl;
   } else if(n <= 10 && m <= 1000) {
       string ans = "";
       int cur = -1;
       for(int i=0; i<(1LL<<n); ++i) {
            string tmp = "";
            int cnt = 0;
            for(int j=0; j<n; ++j) {
                if((1LL<<j)&i) tmp += "R";
                else tmp += "L";
            }
            for(int j=0; j<m; ++j) {
                bool found = 0;
                int tmp2 = 0;
                for(int k=0; k<n; ++k) {
                    if(s[k] >= f[j] && tmp[k] == 'L') {
                        tmp2 = max(tmp2, s[k] - f[j]);
                        found = 1;
                        break;
                    }
                }
                for(int k=n-1; k>=0; --k) {
                    if(s[k] <= f[j] && tmp[k] == 'R') {
                        tmp2 = max(tmp2, f[j] - s[k]);
                        found = 1;
                        break;
                    }
                }
                if(!found) {
                    cnt = -1;
                    break;
                } else cnt = max(cnt, tmp2);
            }
            if(cnt != -1) {
                if(cur == -1 or cnt < cur) {
                    cur = cnt;
                    ans = tmp;
                }
            }
       }
       cout << cur << endl << ans << endl;
   }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 1 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 10 ms 860 KB Correct
3 Correct 1 ms 348 KB Correct
4 Correct 9 ms 1236 KB Correct
5 Correct 7 ms 1112 KB Correct
6 Correct 1 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 2 ms 348 KB Correct
9 Correct 0 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Incorrect 7 ms 1116 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 1 ms 348 KB Correct
3 Incorrect 8 ms 348 KB User solution is worse than jury's solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Incorrect 8 ms 1116 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 1 ms 348 KB Correct
3 Correct 10 ms 860 KB Correct
4 Correct 1 ms 348 KB Correct
5 Correct 9 ms 1236 KB Correct
6 Correct 7 ms 1112 KB Correct
7 Correct 1 ms 348 KB Correct
8 Correct 0 ms 348 KB Correct
9 Correct 2 ms 348 KB Correct
10 Correct 0 ms 348 KB Correct
11 Incorrect 7 ms 1116 KB Unexpected end of file - int32 expected
12 Halted 0 ms 0 KB -