답안 #336231

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
336231 2020-12-15T03:14:38 Z beksultan04 Bigger segments (IZhO19_segments) C++14
0 / 100
19 ms 31596 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int q[N],ct[N],der[4*N],ans,n,dp[N];
vector <pii > v[N];
void rec(int j,int sum,int cnt){
    int i;
    int x = (j*29+sum*29)%N;
    if (dp[x] >= cnt)ret ;
    dp[x]=cnt;
    if (j > n){
        ans = max(ans,cnt);
        ret ;
    }
    for (i=0;i<v[j].size();++i){
        if (v[j][i].fr >= sum){
            rec(v[j][i].sc+1,v[j][i].fr,cnt+1);
        }
    }


}
main(){
    int i,j;
    scan1(n)
    for (i=0;i<N;++i)dp[i]=-1;
    for (i=1;i<=n;++i){
        scan1(q[i])
    }
    for (i=1;i<=n;++i){
        int sum=0;
        for (j=i;j<=n;++j){
            sum+=q[j];
            v[i].pb({sum,j});
        }
    }
    rec(1,0,0);
    cout <<ans;
}

Compilation message

segments.cpp: In function 'void rec(long long int, long long int, long long int)':
segments.cpp:28:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (i=0;i<v[j].size();++i){
      |              ~^~~~~~~~~~~~
segments.cpp: At global scope:
segments.cpp:36:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main(){
      |      ^
segments.cpp: In function 'int main()':
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
segments.cpp:38:5: note: in expansion of macro 'scan1'
   38 |     scan1(n)
      |     ^~~~~
segments.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
segments.cpp:41:9: note: in expansion of macro 'scan1'
   41 |         scan1(q[i])
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31596 KB Output is correct
2 Correct 19 ms 31596 KB Output is correct
3 Correct 18 ms 31596 KB Output is correct
4 Correct 18 ms 31596 KB Output is correct
5 Correct 18 ms 31596 KB Output is correct
6 Correct 18 ms 31596 KB Output is correct
7 Correct 18 ms 31596 KB Output is correct
8 Correct 19 ms 31596 KB Output is correct
9 Correct 19 ms 31596 KB Output is correct
10 Incorrect 18 ms 31596 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31596 KB Output is correct
2 Correct 19 ms 31596 KB Output is correct
3 Correct 18 ms 31596 KB Output is correct
4 Correct 18 ms 31596 KB Output is correct
5 Correct 18 ms 31596 KB Output is correct
6 Correct 18 ms 31596 KB Output is correct
7 Correct 18 ms 31596 KB Output is correct
8 Correct 19 ms 31596 KB Output is correct
9 Correct 19 ms 31596 KB Output is correct
10 Incorrect 18 ms 31596 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31596 KB Output is correct
2 Correct 19 ms 31596 KB Output is correct
3 Correct 18 ms 31596 KB Output is correct
4 Correct 18 ms 31596 KB Output is correct
5 Correct 18 ms 31596 KB Output is correct
6 Correct 18 ms 31596 KB Output is correct
7 Correct 18 ms 31596 KB Output is correct
8 Correct 19 ms 31596 KB Output is correct
9 Correct 19 ms 31596 KB Output is correct
10 Incorrect 18 ms 31596 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31596 KB Output is correct
2 Correct 19 ms 31596 KB Output is correct
3 Correct 18 ms 31596 KB Output is correct
4 Correct 18 ms 31596 KB Output is correct
5 Correct 18 ms 31596 KB Output is correct
6 Correct 18 ms 31596 KB Output is correct
7 Correct 18 ms 31596 KB Output is correct
8 Correct 19 ms 31596 KB Output is correct
9 Correct 19 ms 31596 KB Output is correct
10 Incorrect 18 ms 31596 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 31596 KB Output is correct
2 Correct 19 ms 31596 KB Output is correct
3 Correct 18 ms 31596 KB Output is correct
4 Correct 18 ms 31596 KB Output is correct
5 Correct 18 ms 31596 KB Output is correct
6 Correct 18 ms 31596 KB Output is correct
7 Correct 18 ms 31596 KB Output is correct
8 Correct 19 ms 31596 KB Output is correct
9 Correct 19 ms 31596 KB Output is correct
10 Incorrect 18 ms 31596 KB Output isn't correct
11 Halted 0 ms 0 KB -