p*****2 发帖数: 21240 | 1
object test6 extends App {
val sc=new Scanner(System.in)
val n=sc.nextInt
val m=sc.nextInt
val mat=new Array[String](n)
val start=System.currentTimeMillis()
for(i<-0 until n) mat(i)=sc.next()
def check(i:Int, j:Int, k:Int, l:Int):Boolean={
val minX=math.min(i,k)
val maxX=math.max(i,k)
val minY=math.min(j,l)
val maxY=math.max(j,l)
var minR=true
var maxR=true
var minC=true
var maxC=true
... 阅读全帖 |
|
l***i 发帖数: 1309 | 2 assume all nodes are distinct
1. recursively find maxL and minR, which are max element in root->left
subtree and min element in root->right subtree
2. if maxL > minR, then these two are swapped elements
3. if maxL > root value, then maxL is swapped with root
4. if root value > minR, then minR is swapped with root
5. the only case remain is maxL < root < minR, in this case recurse on both
root->left and root->right because the two swapped nodes must be in the same
subtree now. |
|
d****f 发帖数: 313 | 3 楼上的办法怎么感觉有点不通用阿,我目前自己有个办法,就是先按照PID,DEPTH分组
,求出MIN(Reading)
SELECT PID, DEPTH, MIN(READING) AS MINR
FROM TABLE
WHERE READING>2
GROUP BY PID, DEPTH
然后再基于上面的结论把原表JOIN过来
SELEC A.PID, A.DEPTH, A.MINR, TABLE.PERCENT
FROM
(
SELECT PID, DEPTH, MIN(READING) AS MINR
FROM TABLE
WHERE READING>2
GROUP BY PID, DEPTH
) AS A LEFT JOIN TABLE
ON A.PID=TABLE.PID AND A.DEPTH=TABLE.DEPTH AND A.MINR=TABLE.READING
这样做是不是感觉更通用一些? |
|
a9 发帖数: 21638 | 4 看看这个行不?
update a set a.correlatedidb=d.minres from a left join (
select aid,min(res) minres from
(select a.id aid,b.id bid,min(sqr(a.x-b.x)+sql(a.y-b.y)) res from a cross
join b) c
group by aid) d on a.id=d.aid
Tabl |
|
l*********8 发帖数: 4642 | 5 怎么找maxL 和 minR? 遍历一遍?
both
same |
|