Skip to content

Commit

Permalink
took class
Browse files Browse the repository at this point in the history
  • Loading branch information
Ynng committed Feb 6, 2021
1 parent 11b58da commit 59e9224
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: ccc18s5","url":"f:\\GitHub\\Practice\\CCC\\ccc18s5.cpp","tests":[{"id":1612643370314,"input":"2 3 4 1\n2 3 5\n3 2 7\n1 2 6\n1 1 8\n2 1 5","output":"41"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"f:\\GitHub\\Practice\\CCC\\ccc18s5.cpp","group":"local","local":true}
42 changes: 21 additions & 21 deletions CCC/16s5.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#include <iostream>
#include "math.h"
#include <bits/stdc++.h>
using namespace std;


typedef long long ll;
const int MX = 100000 + 5;

bool circleA[100005];
bool circleB[100005];
bool circleA[MX];
bool circleB[MX];
bool A;
ll n, t;
ll N, T;

ll wrap(ll a, ll b){
ll temp = (a+b)%n;
return temp<0?temp+n:temp;
ll temp = (a+b)%N;
return temp<0?temp+N:temp;
}
void evaluate(ll k){
// printf("evaled %lld\n", k);
for (ll j = 0; j < n; j++)
// printf("evaled %lld\N", k);
for (ll j = 0; j < N; j++)
{
if (A)
circleB[j] = circleA[wrap(j,k)] ^ circleA[wrap(j,-k)];
Expand All @@ -25,29 +27,27 @@ void evaluate(ll k){
}
int main()
{
scanf("%lld %lld", &n, &t);
for (int i = 0; i < n; i++)
{
//only read 1 number
scanf("%1d", &circleA[i]);
}
scanf("%lld %lld", &N, &T);
scanf("%s", circleA); //Why does this work!?
// for (int i = 0; i < N; i++)
// printf("%d ", circleA[i]);
A = true;

ll log2t = log2(t);
ll log2t = log2(T);

for(int i = log2t; i>=1 ; i--){
ll temp = pow(2,i);
if(temp<=t){
t-=temp;
if(temp<=T){
T-=temp;
evaluate(temp);
}
}
if(t==1){
t-=1;
if(T==1){
T-=1;
evaluate(1);
}

for (int i = 0; i < n; i++)
for (int i = 0; i < N; i++)
{
if(A)
printf("%d", circleA[i]);
Expand Down
35 changes: 4 additions & 31 deletions CCC/ccc01s2exact.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define sz(st) (int)(st).size()
#define ms(st, ed) memset(st, ed, sizeof(st))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(st) st.begin(), st.end()
#define ins insert

const int MOD = 1000000007, MX = 20 + 5;

int T, st, ed;
pi shift[] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
int shift[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
int output[MX][MX];

int numberLength(int n)
Expand All @@ -44,7 +17,7 @@ int numberLength(int n)

void solve()
{
memset(output, 0, sizeof(shift));
memset(output, 0, sizeof(output));
scanf("%d %d", &st, &ed);

int length = 0;
Expand All @@ -64,8 +37,8 @@ void solve()

for (int j = 0; j < length && cur <= ed; j++)
{
row += shift[direction].f;
col += shift[direction].s;
row += shift[direction][0];
col += shift[direction][1];
output[row][col] = cur;
output[0][col] = max(output[0][col], numberLength(cur));
b = min(row, b); t = max(row, t); l = min(col, l); r = max(col, r);
Expand Down
105 changes: 105 additions & 0 deletions CCC/ccc18s5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define sz(x) (int)(x).size()
#define ms(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const int MOD = 1000000007, MX = 100000 + 5;

struct E
{
int u, v, w;
bool f;
};

int N, M, P, Q, r[MX], c[MX], row, col;
vector<E> e;
ll tot, mst;

int fd(int d, int p[])
{
if (p[d] != d)
p[d] = fd(p[d], p);
return p[d];
}

int main()
{
scanf("%d %d %d %d", &N, &M, &P, &Q);
row = N;
col = M;
for (int i = 1, u, v, w; i <= P; i++)
{
scanf("%d %d %d", &u, &v, &w);
e.pb(E{u, v, w, 0});
tot += (ll)N * w;
}
for (int i = 1, u, v, w; i <= Q; i++)
{
scanf("%d %d %d", &u, &v, &w);
e.pb(E{u, v, w, 1});
tot += (ll)M * w;
}
sort(all(e), [](E x, E y) { return x.w < y.w; });

/* Disjoint set initialization */
for (int i = 1; i <= N; i++)
r[i] = i;
for (int i = 1; i <= M; i++)
c[i] = i;

for (E x : e)
{
if (x.f)
{ //vertical edge
if (row == 1)
continue;
int fu = fd(x.u, r), fv = fd(x.v, r);
if (fu != fv)
{
r[fu] = fv;
row--;
mst += (ll)x.w * col;
}
}
else
{ //horizontal edge
if (col == 1)
continue;
int fu = fd(x.u, c), fv = fd(x.v, c);
if (fu != fv)
{
c[fu] = fv;
col--;
mst += (ll)x.w * row;
}
}
if (row == 1 && col == 1)
break;
}

printf("%lld", tot - mst);
return 0;
}

0 comments on commit 59e9224

Please sign in to comment.