Skip to content

Commit 4768f58

Browse files
committed
12/04/2021, 22:10:11
1 parent 1183386 commit 4768f58

File tree

14 files changed

+420
-26
lines changed

14 files changed

+420
-26
lines changed

189a.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,17 @@ int main(){
7171
fastio;
7272
int t=1;// cin>>t;
7373
while(t--){
74-
string s; cin>>s;
75-
if(s[0]==s[1] && s[1]==s[2] && isupper(s[0]) && isupper(s[1]) && isupper(s[2]))
76-
cout<<"Won";
77-
else cout<< "Lost";
74+
int n; cin>>n;
75+
int a[n];
76+
FOR(i,0,n) cin>>a[i];
77+
int ans = 0;
78+
FOR(i,0,n) {
79+
int mn = a[i];
80+
FOR(j,i,n) {
81+
mn = min(mn,a[j]);
82+
ans = max(ans, (j-i+1)*mn);
83+
}
84+
}
85+
cout<<ans;
7886
}
7987
}

690c.cpp

+23-22
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,33 @@ using namespace std;
6767

6868
const long long INF = 1e18;
6969
const long long MAX = 2e5+10;
70-
int ans = INT_MAX;
71-
void f(int n, vector<bool>d,int v,int sum){
72-
if(sum>n) return;
73-
74-
if(sum==n) {
75-
ans = min(ans,v);
76-
return;
77-
}
78-
FOR(i,1,10){
79-
if(!d[i]) {
80-
vector<bool>temp=d;
81-
temp[i]=true;
82-
f(n,temp,v*10+i,sum+i);
83-
}
84-
}
85-
86-
}
70+
8771
int main(){
8872
fastio;
8973
int t=1; cin>>t;
9074
while(t--){
9175
int n; cin>>n;
92-
vector<bool>d(10,false);
93-
ans = INT_MAX;
94-
f(n,d,0,0);
95-
if(ans==INT_MAX) cout<<-1<<"\n";
96-
else cout<<ans<<"\n";
76+
string ans;
77+
bool pos = true;
78+
int j=9;
79+
while(n>0){
80+
ROF(i,j,1){
81+
if(n>=i){
82+
ans.push_back('0'+i);
83+
n-=i;
84+
j=i-1;
85+
break;
86+
}
87+
}
88+
89+
if(j==0 && n) {
90+
91+
pos=false; break;
92+
}
93+
}
94+
95+
reverse(ans.begin(),ans.end());
96+
if(!pos) ans = "-1";
97+
cout<<ans<<endl;
9798
}
9899
}

DE.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
4+
5+
void f( int t, vector<string>arr){
6+
int k=0;
7+
int ans = 0;
8+
// while(k<t){
9+
// k++;
10+
// string s=arr[k];
11+
// vector<int>v(30,0);
12+
// int n = s.size();
13+
14+
// FOR(i,0,n){
15+
// v[s[i]-'a']++;
16+
// }
17+
// int o=0,e=0;
18+
// FOR(i,0,26){
19+
// if(v[i]&1) o++;
20+
// else e++;
21+
// }
22+
// if(n&1){
23+
// if(o==1|| o==3) ans++;
24+
// }
25+
// else {
26+
// if(o==2) ans++;
27+
// }
28+
// }
29+
cout<< ans;
30+
}
31+
int main() {
32+
int t; cin>>t; vector<string>v(t);
33+
FOR(i,0,t) cin>>v[i];
34+
f(t,v);
35+
}

DE2.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
#define FOR(i, j, k) for (auto i=j ; i<k ; i++)
5+
int n, m, k;
6+
int dp[71][71][71][71];
7+
int ns[71][71];
8+
int cur;
9+
int solve(int row, int col, int mod, int rem){
10+
11+
if(col==m){
12+
return solve(row+1, 0, mod, m/2);
13+
}
14+
15+
if(row==n){
16+
if(mod==0) return 0;
17+
return -1e9;
18+
}
19+
20+
int &ret=dp[row][col][mod][rem];
21+
if(ret != -1) return ret;
22+
ret=solve(row, col+1, mod, rem);
23+
if(rem) ret=max(ret, ns[row][col]+solve(row, col+1, (mod+ns[row][col])%k, rem-1));
24+
25+
return ret;
26+
27+
}
28+
29+
int main(){
30+
cin >> n >> m >> k;
31+
FOR(i,0,n) FOR(j,0,m) cin >> ns[i][j];
32+
memset(dp, -1, sizeof dp);
33+
int ans=0;
34+
ans = solve(0, 0, 0, m/2);
35+
cout << ans << "\n";
36+
return 0;
37+
}

__pycache__/day.cpython-38.pyc

1.12 KB
Binary file not shown.

a.out

-584 Bytes
Binary file not shown.

cap.cpp

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
#define FOR(i, j, k) for (auto i = j; i < k; i++)
5+
6+
class Graph
7+
{
8+
int V;
9+
int ans = 0;
10+
list<int> *adj;
11+
12+
void DFSUtil(int v, bool visited[]);
13+
14+
public:
15+
Graph(int V);
16+
~Graph();
17+
void addEdge(int v, int w);
18+
int connectedComponents();
19+
};
20+
21+
int Graph::connectedComponents()
22+
{
23+
bool *visited = new bool[V];
24+
for (int v = 0; v < V; v++)
25+
visited[v] = false;
26+
27+
for (int v = 0; v < V; v++)
28+
{
29+
if (visited[v] == false)
30+
{
31+
DFSUtil(v, visited);
32+
ans++;
33+
}
34+
}
35+
delete[] visited;
36+
return ans;
37+
}
38+
39+
void Graph::DFSUtil(int v, bool visited[])
40+
{
41+
visited[v] = true;
42+
43+
list<int>::iterator i;
44+
for (i = adj[v].begin(); i != adj[v].end(); ++i)
45+
if (!visited[*i])
46+
DFSUtil(*i, visited);
47+
}
48+
49+
Graph::Graph(int V)
50+
{
51+
this->V = V;
52+
adj = new list<int>[V];
53+
}
54+
55+
Graph::~Graph() { delete[] adj; }
56+
57+
void Graph::addEdge(int v, int w)
58+
{
59+
adj[v].push_back(w);
60+
adj[w].push_back(v);
61+
}
62+
63+
int main()
64+
{
65+
int n;
66+
cin >> n;
67+
Graph g(n);
68+
69+
FOR(i, 0, n)
70+
FOR(j, 0, n)
71+
{
72+
int x;
73+
cin >> x;
74+
if (x == 1)
75+
{
76+
g.addEdge(i, j);
77+
}
78+
}
79+
cout << g.connectedComponents();
80+
return 0;
81+
}

cap2.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define FOR(i, j, k) for (auto i = j; i < k; i++)
4+
5+
int main() {
6+
int n,k; cin>>n>>k;
7+
map<int,int>mp;
8+
vector<int>mx(n+1,0);
9+
vector<int>adj[n+1];
10+
vector<int>vis(n+1,0);
11+
queue<int>q;
12+
FOR(i,0,k) {
13+
int p; cin>>p;
14+
mp[p]=1;
15+
}
16+
FOR(i,0,n-1){
17+
int u,v; cin>>u>>v;
18+
adj[u].push_back(v);
19+
adj[v].push_back(u);
20+
}
21+
if(mp[n]) mx[n]=1;
22+
q.push(n);
23+
while(!q.empty()){
24+
int u = q.front();
25+
q.pop(); vis[u]=1;
26+
FOR(i,0,adj[u].size()) {
27+
int v= adj[u][i];
28+
if(!vis[v]) {
29+
if(mp[v])
30+
mx[v] = 1 + mx[u];
31+
else mx[v] = mx[u];
32+
q.push(v);
33+
}
34+
}
35+
}
36+
int ans = 0;
37+
FOR(i,0,n+1) ans = max(ans,mx[i]);
38+
cout<<ans;
39+
}

hcc/obj/Debug/net5.0/apphost

0 Bytes
Binary file not shown.

res.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define FOR(i, j, k) for (auto i = j; i < k; i++)
4+
#define time__(d) for (long blockTime = 0; (blockTime == 0 ? (blockTime = clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
5+
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
6+
7+
int main()
8+
{
9+
int m;
10+
cin >> m;
11+
int ans = 0;
12+
time__("code")
13+
{
14+
FOR(i, 1, m)
15+
{
16+
int f = i, s = m - i;
17+
set<int> a; a.insert(1); a.insert(f);
18+
for (int j = 2; j * j <= f; j++)
19+
{
20+
if (f % j == 0)
21+
{
22+
if (j * j == f)
23+
a.insert(j);
24+
else
25+
a.insert(j), a.insert(f / j);
26+
}
27+
}
28+
ans+=distance(a.begin(),a.lower_bound(s));
29+
30+
for (int j = 2; j * j <= s; j++)
31+
{
32+
if (s % j == 0)
33+
{
34+
if (j * j == s)
35+
{
36+
auto it = a.lower_bound(j);
37+
ans += distance(a.begin(), it);
38+
}
39+
else
40+
{
41+
auto it = a.lower_bound(j);
42+
auto it2 = a.lower_bound(s / j);
43+
ans += distance(a.begin(), it) + distance(a.begin(), it2);
44+
}
45+
}
46+
}
47+
}
48+
}
49+
cout << ans;
50+
}

today/__pycache__/day.cpython-38.pyc

1.63 KB
Binary file not shown.

0 commit comments

Comments
 (0)