Submission #260000

# Submission time Handle Problem Language Result Execution time Memory
260000 2020-08-08T22:19:47 Z ly20 Lottery (CEOI18_lot) C++17
0 / 100
101 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 11234;
int eq[MAXN][MAXN], resp[MAXN][MAXN];
int v[MAXN];
int main() {
	int n, l;
	int id = n - l + 1;
	scanf("%d %d", &n, &l);
	for(int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
		for(int j = 0; j < i; j++) {
			if(v[i] != v[j]) continue;
			int ini1 = i - l + 1, fim1 = i, ini2 = j - l + 1, fim2 = j;
			int mn = min(ini1, ini2);
			if(mn < 0) {
				ini1 -= mn; ini2 -= mn;
			}
			int mx = max(fim1, fim2);
			eq[ini1][ini2]++; 
			if(fim1 + 1 < id && fim2 + 1 < id) eq[fim1 + 1][fim2 + 1]--;
			//printf("%d %d %d %d\n", ini1, ini2, fim1, fim2);
		}
	}
	for(int i = 1; i < id; i++) {
		for(int j = 1; j < id; j++) {
			eq[i][j] += eq[i - 1][j - 1];
		}
	}
	for(int i = 0; i < id; i++) {
		for(int j = 0; j < id; j++) {
			resp[i][l - eq[i][j]]++;
		}
	}
	for(int i = 0; i < id; i++) {
		for(int j = 1; j < l; j++) {
			resp[i][j] += resp[i][j - 1];
		}
	}
	int q;
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		int r;
		scanf("%d", &r);
		for(int j = 0; j < id; j++) {
			printf("%d ", resp[j][r]);
		}
		printf("\n");
	}
	return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:19:8: warning: unused variable 'mx' [-Wunused-variable]
    int mx = max(fim1, fim2);
        ^~
lot.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &l);
  ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
   ~~~~~^~~~~~~~~~~~~
lot.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
lot.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &r);
   ~~~~~^~~~~~~~~~
lot.cpp:8:13: warning: 'n' is used uninitialized in this function [-Wuninitialized]
  int id = n - l + 1;
           ~~^~~
lot.cpp:8:13: warning: 'l' is used uninitialized in this function [-Wuninitialized]
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 101 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 101 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -