Reactï¼ãMaterial UIãã§ãããã¼ã®å³ç«¯ã«ã¢ã¤ã³ã³ã表示ããã
ã»åèï¼
ã»ReactのMaterial-UIで、右揃えの要素を作るには | Kanchiの雑記帳
ã»【初心者】#1 Reactの基礎とMaterial-UI使って綺麗に作ってみる #JavaScript - Qiita
ã»èª¬æï¼
ã<div style={{ flexGrow: 1 }}></div>
ã使ãã°è¯ããå ·ä½çã«ã¯ä¸ã®ã³ã¼ãã®Header.jsxãåç §ã
import React from "react"; import AppBar from "@mui/material/AppBar"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; import AccountCircleIcon from "@mui/icons-material/AccountCircle"; const Header = () => { return ( /* ãããã¼ãä¸ã«åºå®*/ <AppBar position="static"> {/*Toolbarãéãç·*/} <Toolbar> <Typography>ãããã¼</Typography> {/*å³å¯ã*/} <div style={{ flexGrow: 1 }}></div> <Typography> <AccountCircleIcon /> </Typography> </Toolbar> </AppBar> ); }; export default Header;
atcoder ABC 325ãC - Sensorsã®Pythonã§ã®èª¬æ
ã»èª¬æ
ãC - Cross
ãã®é¡é¡ããã¨ã«ãã¦è§£ããããã®åé¡ã¯é£æ¥ãã'#'ã®æ°ãæ±ããåé¡ãªã®ã§ãã®åé¡ã®DFSãä»èãã¦ããåé¡ã®ãã¹å
¨ã¦ã§è¡ããé£æ¥ãã'#'ã®æ°ãansã«appendãããçãã¯len(ans)ã«ãªãã
import sys sys.setrecursionlimit(10**6) H,W=map(int,input().split()) map=[list(input()) for _ in range(H)] #é£æ¥ãã'#'ã®æ°ãæ±ããDFSã #ä¾ãã°cnt += dfs(y2, x2)ã¯y3, x3 = y2 + dy, x2 + dx,,,,ã¨ããã¨y3,x3ã¾ã§dfsããå ´åãã¤ã¾ã#ã3åã®ã¨ãã¯cnt=cnt+dfs(y2,x2) = cnt+cnt+dfs(y3,x3) = cnt+cnt+1 (return 1ãã) = 3ã¨ãªã(cnt=1ãã)ã def dfs(x, y): cnt=1 if map[x][y] == "#": map[x][y] = "." for dx in range(-1,2): for dy in range(-1,2): nx = x + dx ny = y + dy if 0 <= nx < H and 0 <= ny < W and map[nx][ny] == "#": cnt+=dfs(nx,ny) return cnt #ansã«'#'ã®åæ°ãå ¥ãã¦ãããçããlen(ans)ã«ãªãã ans=[] for i in range(H): for j in range(W): if map[i][j]=='.': continue ans.append(dfs(i,j)) print(len(ans))
atcoder ABC 323 C - World Tour Finalsã®èª¬æ
ã»èª¬æ
ã'o'ã®åé¡ã¯åã³ä½¿ããªãã®ã§ãç´¯ç©åã¨bisectã ã¨ç¡çãxã®ãã®ãæ½åºãã¦ããããmaxã®ãã®ã¨å¼ãç®ãã¦ãã¤ãã¹ã«ãªãã¾ã§ããã
ã»å¤±æä¾
def II(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LS(): return list(map(str, input().split())) n,m=MI() a=LI() s=[input() for _ in range(n)] import bisect cnt=[i+1 for i in range(n)] #print(s) for i in range(n): for j in range(m): if s[i][j]=='o': cnt[i]+=a[j] a.sort(reverse=True) ruiseki=[0] for i in range(m): tmp=a[i]+ruiseki[i] ruiseki.append(tmp) ma=max(cnt) for i in range(n): if cnt[i]==ma: print(0) continue sa=abs(cnt[i]-ma) bir=bisect.bisect_right(ruiseki,sa) print(bir)
ã»ACä¾
def II(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LS(): return list(map(str, input().split())) n,m=MI() a=LI() s=[input() for _ in range(n)] cnt=[i+1 for i in range(n)] #ç¹æ° flag=[[] for _ in range(n)] #xã®ãã®ãå ¥ãã #'x'ã®ãã®ãæ½åºããã for i in range(n): for j in range(m): if s[i][j]=='o': cnt[i]+=a[j] if s[i][j]=='x': flag[i].append(a[j]) ma=max(cnt) for i in range(n): if cnt[i]==ma: print(0) continue sa=abs(cnt[i]-ma) #ããããã¤ãã¹ã«ãªãã¾ã§'x'ã®ãã®ãå¼ãç®ããã flag[i].sort(reverse=True) ans=0 for f in flag[i]: if sa<0: break sa-=f ans+=1 print(ans)
Python å®å®ã½ã¼ããatcoder ABC323 B - Round-Robin Tournament
ã»åè
docs.python.org
ã»èª¬æ
ã2次å
ã®ãªã¹ãã«ããã¦ãæ®éã®ã½ã¼ãã¨å®å®ã½ã¼ãã使ã£ãå ´åã§æ¯ã¹ããéé ã®ã¨ãã¯å¤ãããªããæé ã®ã¨ãã¯2åç®ã®å¤ãå°ããã®ããå
ã«ä¸¦ã³æ¿ããã
ã»ä¾
ans=[[3, 0], [1, 1], [4, 2], [5, 3], [3, 4], [0, 5], [5, 6]] #æ®éã®ã½ã¼ãã ans.sort() #[[0, 5], [1, 1], [3, 0], [3, 4], [4, 2], [5, 3], [5, 6]] ans.sort(reverse=True) #[[5, 6], [5, 3], [4, 2], [3, 4], [3, 0], [1, 1], [0, 5]] #å®å®ã½ã¼ãã from operator import itemgetter ans=sorted(ans, key=itemgetter(0), reverse=True) #ansã®0åã«å¯¾ãã¦å¤§ããé ã«ä¸¦ã¹ã¦ãåãæansã®1åãè¦ã¦å°ããæ¹ãå ã«ä¸¦ã³æ¿ããã #[[5, 3], [5, 6], [4, 2], [3, 0], [3, 4], [1, 1], [0, 5]] ans=sorted(ans, key=itemgetter(0)) #ansã®0åã«å¯¾ãã¦å°ããé ã«ä¸¦ã¹ã¦ãåãæansã®1åãè¦ã¦å¤§ããæ¹ãå ã«ä¸¦ã³æ¿ããã #[[0, 5], [1, 1], [3, 0], [3, 4], [4, 2], [5, 3], [5, 6]]
ã»ä¾é¡
atcoder.jp
ã»ä¾é¡ã®å®è£ ä¾
n=int(input()) from operator import itemgetter cnt_idx=[i for i in range(n)] cnt=[0]*n for i in range(n): ox=input() for j in range(n): if ox[j]=='o': cnt[i]+=1 ans=[] for i in range(n): ans.append([cnt[i], cnt_idx[i]]) ans=sorted(ans, key=itemgetter(0), reverse=True) for i in range(n): print(ans[i][1]+1, end=" ")
Java Enumã®åå¼·ãvalues()ã¨ãã
ã»èª¬æ
ãJavaã®Enumã«ã¤ãã¦å
·ä½çã«ããã°ã©ã ãåãããªããåå¼·ãããããã°ã©ã ã®èª¬æã¯å®æ°ãApple, Orang, Grapeã¨ããããã®è²ã¨æ°åãgetColor, getNumberã§åå¾ã§ãããã¨ã確èªãããã¾ãvalue()ã使ãã¨å®æ°ãåã£ã¦ããããã¨ã確èªããã
ã»å®è£
//Fruits.java public enum Fruits{ Apple("赤",0), Orange("æ©",1), Grape("é",2); private final String color; //è²ãAppleã ã¨èµ¤ã private final int number; //å é¨å¤æ°ãAppleã ã¨0ã private Fruits(String color,int number){ this.color=color; this.number=number; } //ãã£ã¼ã«ãã®colorãè¿ã. public String getColor(){ return this.color; } public int getNumber(){ return this.number; } }
//ã¡ã¤ã³ //testMain.java public class testMain { public static void main(String[] args) { for (int i=0;i<3;++i){ System.out.println(Fruits.values()[i]); //values()[0]ã¯Apple, values()[1]ã¯Orange,,,ã¨ãªãã } //Apple System.out.println(Fruits.Apple.getColor()); //.Apple.getColorã§Appleã®è²ãã¤ã¾ã赤ãã¨ã£ã¦ããã System.out.println(Fruits.Apple.getNumber()); //Appleã®numberã®0ãã¨ã£ã¦ããã //Orange System.out.println(Fruits.Orange.getColor()); System.out.println(Fruits.Orange.getNumber()); //Grape System.out.println(Fruits.Grape.getColor()); System.out.println(Fruits.Grape.getNumber()); } } //åºå //Apple //Orange //Grape //赤 //0 //æ© //1 //é //2
atcoder ABC 321 C - 321-like Searcherã®èª¬æ
ã»èª¬æ
ã"9876543210"ãæ大ã®çãã«ãªãã®ã§ãã以ä¸ã®å¤ãåæãããä»åã¯itertoolsã®combinationsã使ã£ãã
from itertools import combinations k=int(input()) C=[9,8,7,6,5,4,3,2,1,0] ans=[] for i in range(1,11): for c in combinations(C,i): #ä¾ãã°{9,8}ã98ã¨ããå¤ã«ãã¦ãansã«appendããã tmp=0 for cc in c: tmp=tmp*10+cc ans.append(tmp) ans.sort() print(ans[k])
atcoder ABC320 E - Somen Nagashi ã®SortedListã使ã£ãå®è£
ã»åèã
トヨタ自動車プログラミングコンテスト2023#5(AtCoder Beginner Contest 320) - YouTube
Sorted List — Sorted Containers 2.4.0 documentation
ã»èª¬æ
ãSortedListã使ããã¨ã§å
é ã®è¦ç´ (æé ã«ãªã£ã¦ããã®ã§æå°å¤)ãpop(0)ã使ããO(log (N))ã§åå¾ã§ãããæ®éã®ãªã¹ãã§ã¯popã«å¼æ°ãä»ããã¨O(N)ã«ãªããTLEã«ãªããä»ã«ãheapqãdequeã使ããã¨ã§è§£ããã¨ãã§ãããSortedListã楽ã ã¨æãã
ãããã°ã©ã ã®èª¬æã¯ä»ãåã«ãã人ãorderãåããå¤ãã人ãt_whoã§ç®¡çãã¦ãT以ä¸ã®æéã®ãã®ãorderã«æ»ãã詳ãã説æã¯ã³ã¡ã³ãã¢ã¦ããã¦ããã
from sortedcontainers import SortedList n,m=map(int,input().split()) ans=[0 for _ in range(n)] order=SortedList([i for i in range(n)]) #åã«ãã人ã®é çª. t_who=SortedList() #(æé,ä½çªç®ã®äºº)ã追å ãã¦ãããä½çªç®ã®äººãã©ã®æéã«åã«æ»ãã表ãã for _ in range(m): t,w,s=map(int,input().split()) while len(t_who)!=0: tt,who=t_who.pop(0) #t_whoããt以ä¸ã®æéã®äººãåorderã«æ»ã. if tt<=t: order.add(who) #ããã§ãªãã£ãããpopãããã®ããã¨ã«æ»ãã¦break. else: t_who.add((tt,who)) break if len(order)==0: continue p=order.pop(0) #ãããããé£ã¹ã人. ans[p]+=w t_who.add((t+s,p)) for i in range(n): print(ans[i])