제출 #474192

#제출 시각아이디문제언어결과실행 시간메모리
474192kinglineBootfall (IZhO17_bootfall)C++17
13 / 100
1083 ms320 KiB
#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("avx,avx2,fma") #include <iostream> #include <stdio.h> #include <algorithm> #include <cstdio> #include <cstdlib> #include <iomanip> #include <cmath> #include <vector> #include <string> #include <stack> #include <map> #include <set> #include <queue> #define pb push_back #define F first #define mp make_pair #define S second #define pii pair <int, int > #define pll pair <long long, long long > #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(data) data.begin() , data.end() #define endl '\n' #define bo cout << "OK" << endl; #define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout); //freopen("nenokku_easy.in", "r", stdin); //freopen("nenokku_easy.out", "w", stdout); #define int long long using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; const ll N = 1e6 + 5; const ll mod = 1e9 + 7; const ll INF = 1e10; const ll M = (1 << 17) + 5; const ll LL = 1; const ll p = 31; bool ok; ll q, n, m, k, a[N]; int dp[500 * 500], sum, mn = 501; string s, s1, s2; bool check2(vector < int > &v, int ign) { int sum1 = sum; sum += a[ign]; if(sum1 % 2 == 0) { sum1 /= 2; dp[0] = 1; for(int i = 1; i <= sum1; i++) { dp[i] = 0; } for (int i = 0; i < v.size(); ++i) { if(i == ign) continue; for (int j = sum1; j >= 0; --j) { if (dp[j] == 1 && j + v[i] <= sum1) { dp[j + v[i]] = 1; if(j + v[i] == sum1) return 1; } } }/* cout << "Sum: " << sum1 * 2 << "\n"; for (int i = 0; i < v.size(); ++i) { cout << v[i] << " "; } cout << " --> " << dp[sum1] << "\n";*/ } return 0; } vector < int > v; bool check() { //a[0] = v[0] = val; //cout << "Val: " << val << "\n"; for(int i = 0; i <= n; i++) { /*for(int j = 0; j <= n; j++) { if(i != j) { v.pb(a[j]); //cout << a[j] << " "; } }*/ //cout << endl; sum -= a[i]; if(!check2(v, i)) return 0; } return 1; } main() { //file("B"); //ios; //cin >> n; scanf("%d", &n); v.pb(0); for(int i = 1; i <= n; i++) { //cin >> a[i]; scanf("%d", &a[i]); mn = min(mn, a[i]); sum += a[i]; v.pb(a[i]); } //sort(a + 1, a + n + 1); vector < int > ans; int right = sum - mn; for(int tmp = 1; tmp <= right; tmp++) { sum -= a[0]; v[0] = a[0] = tmp; sum += a[0]; //cout << sum << endl; if(check()) { ans.pb(tmp); } } printf("%d\n", ans.size()); //cout << ans.size() << endl; for(int i = 0; i < ans.size(); i++) { //cout << ans[i] << " "; printf("%d ", ans[i]); } }

컴파일 시 표준 에러 (stderr) 메시지

bootfall.cpp: In function 'bool check2(std::vector<long long int>&, long long int)':
bootfall.cpp:59:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for (int i = 0; i < v.size(); ++i) {
      |                         ~~^~~~~~~~~~
bootfall.cpp: At global scope:
bootfall.cpp:97:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   97 | main()
      | ^~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:102:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
  102 |     scanf("%d", &n);
      |            ~^   ~~
      |             |   |
      |             |   ll* {aka long long int*}
      |             int*
      |            %lld
bootfall.cpp:106:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
  106 |         scanf("%d", &a[i]);
      |                ~^   ~~~~~
      |                 |   |
      |                 |   ll* {aka long long int*}
      |                 int*
      |                %lld
bootfall.cpp:123:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wformat=]
  123 |     printf("%d\n", ans.size());
      |             ~^     ~~~~~~~~~~
      |              |             |
      |              int           std::vector<long long int>::size_type {aka long unsigned int}
      |             %ld
bootfall.cpp:125:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  125 |     for(int i = 0; i < ans.size(); i++) {
      |                    ~~^~~~~~~~~~~~
bootfall.cpp:127:18: warning: format '%d' expects argument of type 'int', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} [-Wformat=]
  127 |         printf("%d ", ans[i]);
      |                 ~^
      |                  |
      |                  int
      |                 %lld
bootfall.cpp:102:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  102 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bootfall.cpp:106:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
#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...