Codejam 2008 qualification round question A

既然写好了模版,不试一下怎么行。

小试之:

'''
CodeJam Practice 2008 qualification round question A
Created on 2012-12-11

@author: festony
'''

from codejam_template_decorator import *

#input_file_path = '..\\inout\\testin.txt'
input_file_path = r'C:\Downloads\codejamtest_p\A-large-practice.in'
output_file_path = r'C:\Downloads\codejamtest_p\A-large-practice.out'

class detector:
    def __init__(self, engines, queries):
        self.engines = engines
        self.queries = queries
        self.engines_cache = set([])
    def detect(self):
        count = 0
        for query in self.queries:
            if query in self.engines:
                self.engines_cache.add(query)
                if len(self.engines_cache) >= len(self.engines):
                    count += 1
                    self.engines_cache.clear()
                    self.engines_cache.add(query)
        return count


@rec_proc_time('Whole')
@redir_stdin(input_file_path)
@output_into_file(output_file_path)
@multi_cases
@rec_proc_time('Case')
def process_func(case_num):
    print 'Round', case_num
    # Put code here
    engines = read_n_strs()
    queries = read_n_strs()
    d = detector(engines, queries)
    count = d.detect()
    
    return 'Case #%d: %d' % (case_num, count)


process_func()



输出:

 

Round 1
Function {Case 1} process time: 7.49674e-05 sec(s)
Round 2
Function {Case 2} process time: 6.18024e-05 sec(s)
Round 3
Function {Case 3} process time: 7.46017e-05 sec(s)
Round 4
Function {Case 4} process time: 6.9482e-05 sec(s)
Round 5
Function {Case 5} process time: 5.48542e-05 sec(s)
Round 6
Function {Case 6} process time: 5.01002e-05 sec(s)
Round 7
Function {Case 7} process time: 0.00173632 sec(s)
Round 8
Function {Case 8} process time: 0.00155713 sec(s)
Round 9
Function {Case 9} process time: 0.000103126 sec(s)
Round 10
Function {Case 10} process time: 0.00297529 sec(s)
Round 11
Function {Case 11} process time: 0.000147741 sec(s)
Round 12
Function {Case 12} process time: 0.000179556 sec(s)
Round 13
Function {Case 13} process time: 7.20419e-05 sec(s)
Round 14
Function {Case 14} process time: 0.00242821 sec(s)
Round 15
Function {Case 15} process time: 0.000113 sec(s)
Round 16
Function {Case 16} process time: 0.00152458 sec(s)
Round 17
Function {Case 17} process time: 0.000317057 sec(s)
Round 18
Function {Case 18} process time: 0.000250501 sec(s)
Round 19
Function {Case 19} process time: 0.000174071 sec(s)
Round 20
Function {Case 20} process time: 0.000200401 sec(s)
Case #1: 0
Case #2: 0
Case #3: 1
Case #4: 1
Case #5: 3
Case #6: 3
Case #7: 999
Case #8: 498
Case #9: 12
Case #10: 1
Case #11: 4
Case #12: 1
Case #13: 6
Case #14: 0
Case #15: 1
Case #16: 11
Case #17: 1
Case #18: 3
Case #19: 3
Case #20: 2

Function {Whole} process time: 0.0133515 sec(s)


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值