답안 #1107474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107474 2024-11-01T09:23:55 Z vjudge1 Kpart (eJOI21_kpart) C++17
0 / 100
2000 ms 38448 KB
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
const int N=2e5+5;
const int inf=1e9;
const int mod=1e9+7;
const int N1=1e6+1;
vector<int>v;
vector<int>v1;
struct edge{
    int v,time;
};
int dp[1001];
signed main(){
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        v.push_back(0);
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            v.push_back(x);
        }
        for(int l=1;l<=n;l++){
            int sum=0;
            for(int r=l;r<=n;r++){
                sum+=v[r];
                v1.push_back(v[r]);
                if(dp[r-l+1]==1){
                    continue;
                }
                if(r-l+1>1){
                    if(sum%2==1){
                        dp[r-l+1]=1;
                        continue;
                    }
                    int cnt=sum/2;
                    sort(v1.begin(),v1.end());
                    for(int i=v1.size()-1;i>=0;i--){
                        if(cnt>=v1[i]){
                            cnt-=v1[i];
                        }
                    }
                    if(cnt!=0){
                        dp[r-l+1]=1;
                    }
                }
            }
            v1.clear();
        }
        int ans=0;
        for(int i=2;i<=n;i++){
            if(dp[i]==0){
                ans++;
            }
        }
        cout<<ans<<" ";
        for(int i=2;i<=n;i++){
            if(dp[i]==0){
                cout<<i<<" ";
            }
            dp[i]=0;
        }
        cout<<"\n";
        v.clear();
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2060 ms 37708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2053 ms 37580 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2057 ms 38448 KB Time limit exceeded
2 Halted 0 ms 0 KB -