Submission #1275739
Source Code Expand
#include "bits/stdc++.h" using namespace std; #define OUT(x) cout << #x << " = " << x << endl; #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) #define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++) #define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++) #define each(i, v) for (auto i : v) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define pb(x) push_back(x) #define bp(x) __builtin_popcount(x) #define mp(x, y) make_pair((x), (y)) #define fi first #define se second #define setp(x) setprecision(x) #define mset(m, v) memset(m, v, sizeof(m)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; static const int MOD = 1000000007; static const double PI = 3.14159265358979; //#define int long long typedef vector<double> vd; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vpii; template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; } template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; } template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; } int in() { int _x; cin >> _x; return _x; } int n, x, m; int l[20], r[20], s[20]; int ans[20]; bool solve(int cur) { if (cur == n) { rep(i, m) { int sum = 0; rer(j, l[i], r[i]) sum += ans[j]; if (sum != s[i]) return false; } rep(i, n) { cout << ans[i] << (i == n - 1 ? '\n' : ' '); } return true; } for (int i = x; i >= 0; i --) { ans[cur] = i; if (solve(cur + 1)) return true; } return false; } signed main() { cin >> n >> x >> m; rep(i, m) { cin >> l[i] >> r[i] >> s[i]; l[i] --; r[i] --; } if (!solve(0)) cout << -1 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - ライオン |
User | KokiYmgch |
Language | C++ (GCC 5.4.1) |
Score | 200 |
Code Size | 2489 Byte |
Status | AC |
Exec Time | 16 ms |
Memory | 256 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 200 / 200 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_test_00.txt, 00_test_01.txt, 00_test_02.txt, 00_test_03.txt, 00_test_04.txt, 00_test_05.txt, 10_random_00.txt, 10_random_01.txt, 10_random_02.txt, 10_random_03.txt, 10_random_04.txt, 10_random_05.txt, 10_random_06.txt, 10_random_07.txt, 10_random_08.txt, 10_random_09.txt, 10_small_10.txt, 10_small_11.txt, 10_small_12.txt, 10_small_13.txt, 10_small_14.txt, 10_small_15.txt, 10_small_16.txt, 10_small_17.txt, 10_small_18.txt, 10_small_19.txt, 10_test_00.txt, 10_test_01.txt, 10_test_02.txt, 10_test_03.txt, 10_test_04.txt, 10_test_05.txt, 10_test_06.txt, 10_test_07.txt, 10_test_08.txt, 10_test_09.txt, 10_test_10.txt, 10_test_11.txt, 10_test_12.txt, 10_test_13.txt, 10_test_14.txt, 10_test_15.txt, 10_test_16.txt, 10_test_17.txt, 10_test_18.txt, 10_test_19.txt, 10_test_20.txt, 10_test_21.txt, 10_test_22.txt, 10_test_23.txt, 10_test_24.txt, 10_test_25.txt, 10_test_26.txt, 10_test_27.txt, 10_test_28.txt, 10_test_29.txt, 10_test_30.txt, 10_test_31.txt, 10_test_32.txt, 10_test_33.txt, 10_test_34.txt, 10_test_35.txt, 10_test_36.txt, 10_test_37.txt, 10_test_38.txt, 10_test_39.txt, 20_random_20.txt, 20_random_21.txt, 20_random_22.txt, 20_random_23.txt, 20_random_24.txt, 20_random_25.txt, 20_random_26.txt, 20_random_27.txt, 20_random_28.txt, 20_random_29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_test_00.txt | AC | 11 ms | 256 KB |
00_test_01.txt | AC | 1 ms | 256 KB |
00_test_02.txt | AC | 1 ms | 256 KB |
00_test_03.txt | AC | 1 ms | 256 KB |
00_test_04.txt | AC | 10 ms | 256 KB |
00_test_05.txt | AC | 1 ms | 256 KB |
10_random_00.txt | AC | 1 ms | 256 KB |
10_random_01.txt | AC | 1 ms | 256 KB |
10_random_02.txt | AC | 1 ms | 256 KB |
10_random_03.txt | AC | 1 ms | 256 KB |
10_random_04.txt | AC | 1 ms | 256 KB |
10_random_05.txt | AC | 1 ms | 256 KB |
10_random_06.txt | AC | 1 ms | 256 KB |
10_random_07.txt | AC | 1 ms | 256 KB |
10_random_08.txt | AC | 1 ms | 256 KB |
10_random_09.txt | AC | 1 ms | 256 KB |
10_small_10.txt | AC | 1 ms | 256 KB |
10_small_11.txt | AC | 1 ms | 256 KB |
10_small_12.txt | AC | 1 ms | 256 KB |
10_small_13.txt | AC | 1 ms | 256 KB |
10_small_14.txt | AC | 1 ms | 256 KB |
10_small_15.txt | AC | 1 ms | 256 KB |
10_small_16.txt | AC | 1 ms | 256 KB |
10_small_17.txt | AC | 1 ms | 256 KB |
10_small_18.txt | AC | 1 ms | 256 KB |
10_small_19.txt | AC | 1 ms | 256 KB |
10_test_00.txt | AC | 1 ms | 256 KB |
10_test_01.txt | AC | 1 ms | 256 KB |
10_test_02.txt | AC | 1 ms | 256 KB |
10_test_03.txt | AC | 1 ms | 256 KB |
10_test_04.txt | AC | 1 ms | 256 KB |
10_test_05.txt | AC | 1 ms | 256 KB |
10_test_06.txt | AC | 1 ms | 256 KB |
10_test_07.txt | AC | 1 ms | 256 KB |
10_test_08.txt | AC | 1 ms | 256 KB |
10_test_09.txt | AC | 1 ms | 256 KB |
10_test_10.txt | AC | 1 ms | 256 KB |
10_test_11.txt | AC | 2 ms | 256 KB |
10_test_12.txt | AC | 1 ms | 256 KB |
10_test_13.txt | AC | 1 ms | 256 KB |
10_test_14.txt | AC | 1 ms | 256 KB |
10_test_15.txt | AC | 2 ms | 256 KB |
10_test_16.txt | AC | 1 ms | 256 KB |
10_test_17.txt | AC | 1 ms | 256 KB |
10_test_18.txt | AC | 1 ms | 256 KB |
10_test_19.txt | AC | 1 ms | 256 KB |
10_test_20.txt | AC | 10 ms | 256 KB |
10_test_21.txt | AC | 11 ms | 256 KB |
10_test_22.txt | AC | 10 ms | 256 KB |
10_test_23.txt | AC | 10 ms | 256 KB |
10_test_24.txt | AC | 13 ms | 256 KB |
10_test_25.txt | AC | 10 ms | 256 KB |
10_test_26.txt | AC | 10 ms | 256 KB |
10_test_27.txt | AC | 11 ms | 256 KB |
10_test_28.txt | AC | 1 ms | 256 KB |
10_test_29.txt | AC | 10 ms | 256 KB |
10_test_30.txt | AC | 2 ms | 256 KB |
10_test_31.txt | AC | 1 ms | 256 KB |
10_test_32.txt | AC | 5 ms | 256 KB |
10_test_33.txt | AC | 2 ms | 256 KB |
10_test_34.txt | AC | 2 ms | 256 KB |
10_test_35.txt | AC | 7 ms | 256 KB |
10_test_36.txt | AC | 1 ms | 256 KB |
10_test_37.txt | AC | 4 ms | 256 KB |
10_test_38.txt | AC | 5 ms | 256 KB |
10_test_39.txt | AC | 2 ms | 256 KB |
20_random_20.txt | AC | 10 ms | 256 KB |
20_random_21.txt | AC | 14 ms | 256 KB |
20_random_22.txt | AC | 11 ms | 256 KB |
20_random_23.txt | AC | 14 ms | 256 KB |
20_random_24.txt | AC | 10 ms | 256 KB |
20_random_25.txt | AC | 15 ms | 256 KB |
20_random_26.txt | AC | 14 ms | 256 KB |
20_random_27.txt | AC | 12 ms | 256 KB |
20_random_28.txt | AC | 16 ms | 256 KB |
20_random_29.txt | AC | 10 ms | 256 KB |