結果
| 問題 | No.115 遠足のおやつ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-29 14:36:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 490 bytes |
| 記録 | |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 38,912 KB |
| 実行使用メモリ | 9,756 KB |
| 最終ジャッジ日時 | 2024-06-13 01:01:29 |
| 合計ジャッジ時間 | 10,605 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 16 TLE * 1 -- * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d%d%d",&n,&d,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <vector>
#include <cstdio>
#include <cstdlib>
using namespace std;
void dfs(vector<int>&v,int s,int t,int i,int n,int d,int k){
if(d==k-1){
int x=t-s;
if(i<x&&x<=n){
for(int j=0;j<v.size();j++)printf("%d ",v[j]);
printf("%d\n",x);
exit(0);
}
}else{
for(;i<=n;i++){
if(s+i<t){
v.push_back(i);
dfs(v,s+i,t,i+1,n,d+1,k);
v.pop_back();
}
}
}
}
int main(){
int n,d,k;
scanf("%d%d%d",&n,&d,&k);
vector<int>v;
dfs(v,0,d,1,n,0,k);
puts("-1");
}