wat

Golang: Having trouble with nested JSON Unmarshaler

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Given the following code: package main import ( "encoding/json" "log" ) type Somefin string func (s *Somefin) UnmarshalJSON(b []byte) error { log.Println("Unmarshaling",string(b)) *s = Somefin("~"+string(b)+"~") return nil } type Wat struct { A, B string *Somefin } func main() { b := []byte(`{"A":"foo","B":"bar","Somefin":"baz"}`) w := &Wat{Somefin: new(Somefin)} err := json.Unmarshal(b,w) log.Println(w, err) } I get the following output: # go run wat.go 2013/12/14 13:59:17 Unmarshaling {"A":"foo","B":"bar","Somefin":"baz"} 2013/12/14 13:59

csp-c模拟测试43「A·B·C」

此生再无相见时 提交于 2019-11-29 17:15:44
A 题解 代码 B 题解 代码 C 题解 三分,对于怎么看出来三分,这可能是个套路,你觉得这个题你用贪心做不了 (但非常像贪心), 二分答案会被hack , 然后你$dp$也难以做,你三分就可以了 三分$check$贪心做,很水,我会说 代码 /* n*log^2 */ #include<bits/stdc++.h> using namespace std; #define ll long long #define A 222222 struct node{ ll l,r; friend bool operator < (const node & a,const node &b){ return a.l==b.l?a.r>b.r:a.l<b.l; } }wat[A]; ll n,m,t,ans=0x7fffffffffffff,maxx=0,cnt=0; ll p[A],lef[A],now[A],c[A]; ll check(ll x){ ll sum=0; for(ll i=1;i<=n;i++){ now[i]=max(p[i]-x,0ll); c[i]=0; } for(ll i=1;i<=n;i++){ ll nowid=lef[i]; c[i]+=c[i-1]; if(lef[i]==0) continue ; ll cha=c[i]; // printf("i=