Submission #171754


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <sstream>
#include <functional>
#include <complex>

using namespace std;

#define len(array)  (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = (s);i < (e);i++)
#define Rep(i, e) for(int i = 0;i < (e);i++)
#define rrep(i, e, s) for(int i = (e);(s) <= i;i--)
#define Rrep(i, e) for(int i = e;0 <= i;i--)
#define mrep(i, e, t1, t2) for(map<t1, t2>::iterator i = e.begin(); i != e.end(); i++)
#define vrange(v) v.begin(), v.end()
#define vrrange(v) v.rbegin(), v.rend()
#define vsort(v) sort(vrange(v))
#define vrsort(v) sort(vrrange(v))
#define arange(a) a, a + len(a)
#define asort(a) sort(arange(a))
#define arsort(a, t) sort(arange(a), greater<t>())
#define afill(a, v) fill(arange(a), v)
#define afill2(a, v, t) fill((t *)(a), (t *)((a) + len(a)), v)
#define fmax(a, b) ((a) < (b)? (b) : (a))
#define fmin(a, b) ((a) > (b)? (b) : (a))
#define fabs(a) ((a) < 0? -(a) : (a))
#define pb push_back
#define fst(e) (e).first
#define snd(e) (e).second
#define rg(e, s, t) (s <= e && e < t)
#define PQDecl(name, tp) priority_queue< tp, vector<tp>, greater<tp> > name
#define dq(q) q.top();q.pop();
#define sz(v) ((int)(v).size())
#define lg(s) ((int)(s).length())
//#define X real()
//#define Y imag()
//typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<int> VI;
//typedef complex<double> p;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
//const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//const ll weight[] = {1e0,1e1,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13};
typedef struct _Datum {
  int fst,snd,trd;
  _Datum(int arg1 = 0, int arg2 = 0 , int arg3 = 0) {
	fst = arg1; snd = arg2; trd = arg3;
  }
  bool operator <(const struct _Datum &e) const{
    return fst == e.fst? (snd == e.snd? trd < e.trd : snd < e.snd) : fst < e.fst;
  }
  bool operator >(const struct _Datum &e) const{
    return fst == e.fst? (snd == e.snd? trd > e.trd : snd > e.snd) : fst > e.fst;
  }
}datum;


void prtAI(int *a, int n, bool display = true){
    if(display) printf("---printAI---\n");
    Rep(i, n) printf("%d%c", a[i], i==n-1?'\n':' ');
    if(display) printf("-----------------\n");
}
void prtVI(const VI &v, bool display = true){
    if(display) printf("-----printVI-----\n");
    Rep(i, sz(v)) printf("%d%c", v[i], i==sz(v)-1?'\n':' ');
    if(display) printf("-----------------\n");
}

#define MAX_N 100005
ll a[2005], dp[2005][2005];


void solve(){
    int n;
    cin >> n;
    Rep(i, n) scanf("%lld", &a[i]);
    // afill2(dp, 0, ll);
    dp[0][0] = 1;
    Rep(i, n){
        if(a[i] == -1){
            ll sum = 0;
            Rep(j, 2002){
                sum = (sum + dp[i][j]) % MOD;
                dp[i+1][j] = sum;
            }
        } else{
            Rep(j, a[i]+1){
                dp[i+1][a[i]] = (dp[i][j] + dp[i+1][a[i]]) % MOD;
            }
        }
    }
    ll ans = 0;
    Rep(i, 2002){
        ans = (ans + dp[n][i]) % MOD;
    }
    cout << ans << endl;

}

void doIt(){
  int t = 1;
  // scanf("%d", &t);
  while(t--){
    solve();
  }
}

int main() {
  doIt();
  return 0;
}

Submission Info

Submission Time
Task C - タコヤ木
User mkiken
Language C++ (G++ 4.6.4)
Score 80
Code Size 3566 Byte
Status RE
Exec Time 498 ms
Memory 32044 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:93:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 50 / 50 30 / 30 0 / 20
Status
AC × 2
RE × 1
AC × 14
AC × 26
AC × 24
RE × 12
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Subtask2 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Case Name Status Exec Time Memory
sample_01.txt AC 20 ms 808 KB
sample_02.txt AC 22 ms 912 KB
sample_03.txt RE 371 ms 924 KB
subtask1_01.txt AC 21 ms 812 KB
subtask1_02.txt AC 20 ms 912 KB
subtask1_03.txt AC 22 ms 924 KB
subtask1_04.txt AC 24 ms 1952 KB
subtask1_05.txt AC 24 ms 1916 KB
subtask1_06.txt AC 21 ms 1688 KB
subtask1_07.txt AC 28 ms 2328 KB
subtask1_08.txt AC 23 ms 1304 KB
subtask1_09.txt AC 23 ms 2200 KB
subtask1_10.txt AC 21 ms 1684 KB
subtask1_11.txt AC 23 ms 1688 KB
subtask1_12.txt AC 25 ms 2200 KB
subtask2_01.txt AC 19 ms 912 KB
subtask2_02.txt AC 24 ms 796 KB
subtask2_03.txt AC 21 ms 916 KB
subtask2_04.txt AC 31 ms 3884 KB
subtask2_05.txt AC 44 ms 8868 KB
subtask2_06.txt AC 43 ms 7760 KB
subtask2_07.txt AC 103 ms 32044 KB
subtask2_08.txt AC 68 ms 8736 KB
subtask2_09.txt AC 100 ms 30372 KB
subtask2_10.txt AC 99 ms 30888 KB
subtask2_11.txt AC 80 ms 15276 KB
subtask2_12.txt AC 83 ms 19108 KB
subtask3_01.txt RE 232 ms 788 KB
subtask3_02.txt RE 233 ms 796 KB
subtask3_03.txt RE 236 ms 792 KB
subtask3_04.txt RE 483 ms 932 KB
subtask3_05.txt RE 248 ms 916 KB
subtask3_06.txt RE 498 ms 936 KB
subtask3_07.txt RE 314 ms 32040 KB
subtask3_08.txt RE 287 ms 920 KB
subtask3_09.txt RE 232 ms 920 KB
subtask3_10.txt RE 388 ms 924 KB
subtask3_11.txt RE 240 ms 924 KB
subtask3_12.txt RE 338 ms 924 KB