Submission #2279294


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,x,m;
  cin>>n>>x>>m;
  vector<Int> l(m),r(m),s(m);
  for(Int i=0;i<m;i++) cin>>l[i]>>r[i]>>s[i];
  vector<Int> ans(n,-1);
  vector<Int> tmp(n,0);
  Int sum=0;
  function<void(Int)> dfs=[&](Int idx){
    if(idx==n){
      vector<Int> su(n+1,0);
      for(Int i=0;i<n;i++) su[i+1]=su[i]+tmp[i];
      for(Int i=0;i<m;i++)
	if(su[r[i]]-su[l[i]-1]!=s[i]) return;
      if(ans[0]<0||sum<su[n]) ans=tmp,sum=su[n];
      return;
    }
    for(Int i=0;i<=x;i++){
      tmp[idx]=i;
      dfs(idx+1);
    }
  };
  dfs(0);
  if(ans[0]<0) cout<<-1<<endl;
  else{
    for(Int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<ans[i];
    }
    cout<<endl;
  }
  return 0;
}

Submission Info

Submission Time
Task B - ライオン
User beet
Language C++14 (GCC 5.4.1)
Score 200
Code Size 808 Byte
Status AC
Exec Time 81 ms
Memory 384 KB

Judge Result

Set Name All
Score / Max Score 200 / 200
Status
AC × 76
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 79 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 79 ms 256 KB
00_test_05.txt AC 79 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 3 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 2 ms 384 KB
10_test_09.txt AC 1 ms 256 KB
10_test_10.txt AC 2 ms 256 KB
10_test_11.txt AC 5 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 6 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 79 ms 256 KB
10_test_21.txt AC 79 ms 256 KB
10_test_22.txt AC 79 ms 256 KB
10_test_23.txt AC 79 ms 256 KB
10_test_24.txt AC 80 ms 256 KB
10_test_25.txt AC 81 ms 256 KB
10_test_26.txt AC 79 ms 256 KB
10_test_27.txt AC 79 ms 256 KB
10_test_28.txt AC 79 ms 256 KB
10_test_29.txt AC 79 ms 256 KB
10_test_30.txt AC 79 ms 256 KB
10_test_31.txt AC 80 ms 256 KB
10_test_32.txt AC 79 ms 256 KB
10_test_33.txt AC 81 ms 256 KB
10_test_34.txt AC 81 ms 256 KB
10_test_35.txt AC 79 ms 256 KB
10_test_36.txt AC 78 ms 256 KB
10_test_37.txt AC 80 ms 256 KB
10_test_38.txt AC 80 ms 256 KB
10_test_39.txt AC 79 ms 256 KB
20_random_20.txt AC 79 ms 256 KB
20_random_21.txt AC 79 ms 256 KB
20_random_22.txt AC 79 ms 256 KB
20_random_23.txt AC 79 ms 256 KB
20_random_24.txt AC 79 ms 256 KB
20_random_25.txt AC 79 ms 256 KB
20_random_26.txt AC 79 ms 256 KB
20_random_27.txt AC 79 ms 256 KB
20_random_28.txt AC 80 ms 256 KB
20_random_29.txt AC 79 ms 256 KB