結果
| 問題 |
No.8021 データベースの練習
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2016-09-23 22:23:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,605 bytes |
| コンパイル時間 | 195 ms |
| コンパイル使用メモリ | 82,200 KB |
| 実行使用メモリ | 93,156 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2024-07-16 11:05:12 |
| 合計ジャッジ時間 | 4,150 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 12 |
ソースコード
# ジャッジコード
import sqlite3
import random
import sys
#run_type = "generator"
run_type = "judge"
argvs = sys.argv
argc = len(argvs)
#assert(argc > 2)
print(argvs, file=sys.stderr)
n,q,w,h,seed = map(int, open(argvs[1],"r").read().split())
print(n,q,seed, file=sys.stderr)
assert((w+1)*(h+1) >= n)
random.seed( seed )
s = set()
#generate points
while len(s) < n :
s.add( (random.randint(0,w), random.randint(0,h)) )
#initialize database
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
cur.execute("""
CREATE TABLE point(
id INTEGER PRIMARY KEY,
x INTEGER,
y INTEGER);
""")
for p in s :
cur.execute("""INSERT INTO point(x,y) VALUES(?,?);""", [(p[0]),(p[1])])
print(p, file=sys.stderr)
if run_type == "judge" :
print(q)
for i in range(q) :
xl = random.randint(0,w)
xh = random.randint(0,w)
yl = random.randint(0,h)
yh = random.randint(0,h)
if xl > xh :
xl, xh = xh, xl
if yl > yh :
yl, yh = yh, yl
assert(xl<=xh)
assert(yl<=yh)
if run_type == "judge" :
print(xl,xh,yl,yh)
else :
cur.execute("""SELECT count(*) FROM point WHERE (x BETWEEN ? and ?) and (y BETWEEN ? and ?);""", [(xl),(xh),(yl),(yh)])
print(cur.fetchone()[0])
if run_type == "judge" :
res = []
sql_scripts = sys.stdin.read().split(';')
for scr in sql_scripts :
cur.execute(scr + ";")
var = cur.fetchone()
while var != None :
res.append(var[0])
var = cur.fetchone()
ans = list( map(int, open(argvs[2], "r").read().split() ) )
print(res, file=sys.stderr)
print(ans, file=sys.stderr)
assert(res == ans)
koyumeishi