답안 #170181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170181 2019-12-24T07:36:48 Z ics0503 Languages (IOI10_languages) C++17
0 / 100
10000 ms 198456 KB
#include <stdlib.h>
#include <stdio.h>
#include <map>
using namespace std;

#include "grader.h"
#include "lang.h"

#define SZ 100
int num[56][65536], ccnt = 0, commonChar[65536], uniqueChar[65536];
int mod = 499973;
map<long long, int> num2[56], num3[56];
long long hash2(long long x, long long y) {
	return x * 65536 + y;
}
long long hash3(long long x, long long y, long long z) {
	return (((x * 65536 + y) )*65536 + z);
}
int pandan(int *E) {
	int nE[222] = { 0, }, n=0, i, j;
	for (i = 0; i < 100; i++) if (uniqueChar[E[i]] != -1) return uniqueChar[E[i]];
	int js[56] = { 0, };
	for (i = 1; i < 100; i++) {
		long long g = hash2(E[i - 1], E[i]);
		for (j = 0; j < 56; j++) {
			js[j] += num2[j][g];
		}
	}
	for (i = 2; i < 100; i++) {
		long long g = hash3(E[i-2], E[i - 1], E[i]);
		for (j = 0; j < 56; j++) {
			js[j] += num3[j][g]*3;
		}
	}
	int mx = -1, mxw = 0;
	for (i = 0; i < 56; i++) if (mx < js[i])mx = js[i], mxw = i;
	return mxw;
}
void learn(int *E, int ans) {
	int i, j, k;
	for (i = 0; i < 100; i++) num[ans][E[i]] = 1;
	for (i = 1; i < 100; i++) num2[ans][hash2(E[i - 1], E[i])] = 1;
	for (i = 2; i < 100; i++) num3[ans][hash3(E[i - 2], E[i - 1], E[i])] = 1;
	for (i = 0; i < 100; i++) {
		int cr = E[i];
		int cnt = 0, w = -1;
		for (j = 0; j < 56; j++) {
			if (num[j][cr]) {
				cnt++;
				w = j;
			}
		}
		commonChar[cr] = cnt>20?1:0;
		uniqueChar[cr] = cnt==1?w:-1;
	}
}
void excerpt(int *E) {
	int i, j;
	ccnt++;
	int ans = language(pandan(E));
	learn(E, ans);
}

Compilation message

lang.cpp: In function 'int pandan(int*)':
lang.cpp:20:6: warning: unused variable 'nE' [-Wunused-variable]
  int nE[222] = { 0, }, n=0, i, j;
      ^~
lang.cpp:20:24: warning: unused variable 'n' [-Wunused-variable]
  int nE[222] = { 0, }, n=0, i, j;
                        ^
lang.cpp: In function 'void learn(int*, int)':
lang.cpp:40:12: warning: unused variable 'k' [-Wunused-variable]
  int i, j, k;
            ^
lang.cpp: In function 'void excerpt(int*)':
lang.cpp:58:6: warning: unused variable 'i' [-Wunused-variable]
  int i, j;
      ^
lang.cpp:58:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10058 ms 191724 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10116 ms 198456 KB Time limit exceeded