656 字 1 分鐘

# 題目 zerojudge c123. 00514 - Rails # 解題思路 目前沒東西... # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 1005int n,temp;stack<int> stk;bool test(stack<int> &_stk,int n){ stack<int> tstk; while(!_stk.empty()){...
599 字 1 分鐘

# 題目 zerojudge j608. 4. 機器出租 # 解題思路 目前沒東西... # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 100005bool cmp(pair<int,int> a,pair<int,int> b){ return a.second<b.second;}int n,k,ans;multiset<int> ms;pair<int,int>...
687 字 1 分鐘

# 題目 AP325 Q-7-8. 小寶的著色問題 # 解題思路 O(n+m) # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 10005int t,n,m,color[N];vector<int> adj[N];bool c;void dfs(int p){ for(auto e:adj[p]){ if(color[e]==0){ if(color[p]==1) color[e]=2; else color[e]=1;...
1.1k 字 1 分鐘

# 題目 AP325 Q-7-7. AOV 最早完工時間 # 解題思路 O(n+m) # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 10005int n,m,dis,w[N];//in-degree 入度bool done[N],indeg[N];vector<int> adj[N],ans;set<int> st;void f(int p){ if(indeg[p]==0) return; int mx=0; for(auto...
737 字 1 分鐘

# 題目 zerojudge e810. 2. 潛水 (Diving) # 解題思路 目前沒東西... # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 505vector<pair<int,int>> adj[N];int n,m,A,B,done[N],apcacity;// 容量int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n>>m; for(int...
1.3k 字 1 分鐘

# 題目 zerojudge j123: 2. 運貨站 # 解題思路 O(c * r * n) # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 55struct range{ int x,y;};bool block[5][4][3],Fs[N][N];//Freight stationint r,c,n,space,block_s[5]={4,3,4,4,5},trash;range...
1.1k 字 1 分鐘

# 題目 AP325 Q-8-16. 病毒演化 (APCS202007) # 解題思路 O(nm) # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 1005#define INF 1147483647//2^31-1-10^9#define T 5vector<int> v[N];int n,m,root,dp[N][5],ans;string s[N];//{'@',0}...
395 字 1 分鐘

# 題目 AP325 Q-2-4. 快速冪 --200 位整數 # 解題思路 目前沒東西... # 程式碼 #include <bits/stdc++.h>using namespace std;typedef long long LL;LL a,b,c;string s;LL superpow(int x,int y,int z){ if(y==0) return 1; if(y&1) return superpow(x,y-1,z)*x%z; LL sp=superpow(x,y/2,z)%z; return...
634 字 1 分鐘

# 題目 zerojudge f315. 4. 低地距離 # 解題思路 目前沒東西... # 程式碼 #include<bits/stdc++.h>using namespace std;#define N 100005typedef long long LL;pair<int,bool> a[N<<1];bool c[N];LL inv(int l,int r){ if(l+1==r) return 0; int m=(l+r)>>1; LL ans=inv(l,m)+inv(m,r);...