text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; string p; bool cap = false, l = false, dig = false; char digits[10] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }; int main() { cin >> p; int s = p.length(); if (s < 5) { cout << Too weak ; return 0; } for (int i = 0; i < s;...
#include <bits/stdc++.h> using namespace std; char buf[10001], buf2[1000001]; int tab[100001][26]; int main() { scanf( %s %s , buf, buf2); int len = strlen(buf), len2 = strlen(buf2); for (int i = 0; i < 26; i++) tab[len - 1][i] = -1; for (int ti = 2 * len - 2; ti >= 0; ti--) { int i = ti %...
#include <bits/stdc++.h> using namespace std; int n, m, dx[]{-1, 0, 0, 1}, dy[]{0, -1, 1, 0}; vector<string> tab; vector<vector<int>> dist; priority_queue<pair<int, pair<int, int>>> PQ; int dijkstra(int x, int y) { dist.assign(n, vector<int>(m, INT_MAX / 2)); dist[x][y] = 1; PQ.push({0, {x, y}})...
#include <bits/stdc++.h> using namespace std; int main() { string s1; while (cin >> s1) { string s2 = ; for (int i = 0; i < s1.size(); i++) { if (s1[i] != + ) s2 += s1[i]; } sort(s2.begin(), s2.end()); for (int i = 0; i < s2.size(); i++) { if (i) cout << + ;...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cin.ignore(); while (n--) { string str1, str2; getline(cin, str1); getline(cin, str2); bool test = true; long long j = 0, i = 0; char last_ch = str1[0]; while (j < str2.size() ...
// MBT 10-29-14 // // `include "bsg_defines.v" module bsg_nonsynth_ascii_writer #(parameter `BSG_INV_PARAM(width_p ) , parameter `BSG_INV_PARAM(values_p ) , parameter `BSG_INV_PARAM(filename_p ) , parameter fopen_param_p = "w" , parameter format_p = "%x ") (input clk , input reset_i ...
//----------------------------------------------------------------------------- // // (c) Copyright 2010-2011 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property ...
/*. * DSI Shield * Copyright (C) 2013-2014 twl <> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * Th...
#include <bits/stdc++.h> using namespace std; const double PI = 2.0 * acos(0.0); inline int getInt() { int x; scanf( %d , &x); return x; } inline long long getLL() { long long x; scanf( %lld , &x); return x; }; inline int NUM(char c) { return (int)c - 48; } inline char CHR(int n)...
///////////////////////////////////////////////////// // DCM SPI Controller ///////////////////////////////////////////////////// `timescale 1ns / 1ps module dcmspi ( input RST, //Synchronous Reset input PROGCLK, //SPI clock input PROGDONE, //DCM is ready to take next...
#include <bits/stdc++.h> using namespace std; const int MM = 1005; const long long MOD = 1000000007; int vis[MM][MM] = {0}; int n, m, k; bool judge(int x, int y) { if (x - 1 >= 0 && y - 1 >= 0) { if (vis[x - 1][y - 1] && vis[x - 1][y] && vis[x][y - 1]) return true; } if (x - 1 >= 0 && y + ...
#include <bits/stdc++.h> using namespace std; const int N = 400005; int n, q, K, m, i, j, k, h[N], t[N], num, fa[N], s[N], id[N], size[N], son[N], tp[N], dep[N], head[N], adj[N * 2], nxt[N * 2], p[N], cnt, stk[N], top, g[N], Head[N], Adj[N * 2], Nxt[N * 2], l, f[N]; void dfs(int x, int dad) { si...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS = 1; while (TESTS--) { int n; cin >> n; vector<long long int> a(n); for (long long int i = 0; i < n; i++) cin >> a[i]; sort((a).begin(), (...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// (C) 2001-2015 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated doc...
#include <bits/stdc++.h> using namespace std; int n, q, fa[50005], ff[50005], h[50005], tot, e[50005 << 1], nxt[50005 << 1], mx[50005][256], cnt[50005][256], Ans[50005][256], ans, val[50005], dep[50005]; template <class T> inline void read(T &x) { x = 0; bool emm = 1; char c; for (c ...
/* This file is part of JT12. JT12 program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. JT12 program is distribute...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Wed Mar 01 09:52:04 2017 // Host : GILAMONSTER running 64-bit major release (...
//---------------------------------------------------------------------------- // // COPYRIGHT (C) 2011, VIPcore Group, Fudan University // // THIS FILE MAY NOT BE MODIFIED OR REDISTR...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int t; cin >> t; while (t--) { long long int n, k; cin >> n >> k; long long int q = k / (n - 1); long long int r = k % (n - 1); if (r == 0) { cout << n * q - 1 << n ; } else { ...
`default_nettype none module mmu_table_load( input wire iCLOCK, input wire inRESET, input wire iRESET_SYNC, //Load Req input wire iLD_REQ, input wire [31:0] iLD_ADDR, output wire oLD_BUSY, //Memory Pipe - REQ output wire oMEM_REQ, input wire iMEM_LOCK, output wire [31:0] oMEM_ADDR, //Memory ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; vector<int> b(a); vector<int> c(a); for (int i = 0; i < a; i++) { cin >> b[i]; c[i] = b[i]; } sort(b.begin(), b.end()); int i0 = 0, i1 = 0; for (int i = 0; i < a; i++) { if (c[i] == b[0]...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1 ns / 1 ps module intermediator( input reset, input clk, input valid0, input [63:0] value0, input [9:0] row0, input valid1, input [63:0] value1, input [9:0] row1, output store, output [63:0] store_value, output add, output [63:0] add0, output [63:0] add1, ...
#include <bits/stdc++.h> using namespace std; const int N = 200007; int n, m, q, p[N], a[N], apre[N], lst[N], ppre[N], fa[N], dep[N], w[N], b[N]; vector<int> G[N]; int max(int a, int b) { return a > b ? a : b; } int min(int a, int b) { return a < b ? a : b; } int read() { int x; scanf( %d , &x); ...
// megafunction wizard: %RAM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: wb_ram_32x8192.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =====================...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:2000000 ) #pragma comment(linker, /HEAP:2000000 ) using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; long long m[n][n], a[n]; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; char inp[200005]; int main() { bool ok; queue<int> zeroes, ones; vector<int> vec[200005]; int n_vec = 0, n_z = 0, n_o = 0, tam; scanf( %s , inp); tam = strlen(inp); if (inp[0] == 1 ) cout << -1 << endl; else { vec[n_vec++]....
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
//############################################################################# //# Function: Generic Memory # //############################################################################# //# Author: Andreas Olofsson # ...
/* ------------------------------------------------------------------------------- * (C)2007 Robert Mullins * Computer Architecture Group, Computer Laboratory * University of Cambridge, UK. * ------------------------------------------------------------------------------- * * Physical-Channel (Channel-level) Flow-...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distribut...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > Sh; const int tmax = 155; char table[tmax][tmax]; pair<int, int> mow[tmax]; pair<int, int> ccount(int row, int side, int ai) { if (mow[row].second == 0 && mow[row + 1].second == 0) return make_pair(0, ai); if (mow[row].second == 0...
// // Copyright (c) 1999 Steven Wilson () // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // ...
#include <bits/stdc++.h> using namespace std; int ans = 0, visited[200005] = {0}; vector<int> edges[200005]; void dfs(int x) { visited[x] = 1; if (visited[edges[x][0]] == 1) ans++; else dfs(edges[x][0]); } int main() { int n, i, x, count = 0; cin >> n; for (i = 1; i <= n;...
#include <bits/stdc++.h> using namespace std; vector<string> tmp; long long num(string str) { int len = str.size(); long long res = 0; for (int i = 0; i < len; i++) { res = res * 10 + str[i] - 0 ; } return res; } void solve(int N) { queue<string> q; q.push( 11 ); q.push(...
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; long long a1[n], b1[n]; for (int i = 0; i < n; i++) cin >> a1[i] >> b1[i]; long long dp[n][k]; vector<long long> a, b; vector<pair<pair<long long, long long>, long long> > e; vector<long long> ans; ...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int MX_N = (1e3) + 3; int a[MX_N][MX_N]; int main() { int n; scanf( %d , &n); if (n == 4) puts( -1 ); else { for (int i = 0; i < n; ++i) { for (int j = i - 2; j >= 0; j -= 2) a[i][j] = 1; for (int j = i + 1; j < n; j...
#include <bits/stdc++.h> using namespace std; list<char> lanc; using It = list<char>::iterator; bool torolni_kell(It mit) { if (*mit == - ) return false; char akt = *mit, el = *prev(mit), kov = *next(mit); return (el != - && el != akt) || (kov != - && kov != akt); } int main() { ios_bas...
#include <bits/stdc++.h> using namespace std; typedef const int &ci; inline int read() { int x = 0; char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); while ( 0 <= c && c <= 9 ) x = 10 * x + c - 0 , c = getchar(); return x; } inline void Max(int &x, ci y) { if (x < y) x =...
#include <bits/stdc++.h> using namespace std; const int MX = 100 * 1000 + 7; int a[MX]; int hup[MX], hdown[MX]; long long cup[MX], cdown[MX]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } for (int i = 1; i <= n; i++) { int cost = 0;...
// file: int_skew_dcm.v // // (c) Copyright 2008 - 2011 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclai...
#include <bits/stdc++.h> using namespace std; const int maxl = 100000; map<int, int> SG, num; int n, x, tmp, ans = 0, prime[maxl], tot = 0; bool notprime[maxl + 1]; inline void init() { notprime[1] = 1; for (int i = 2; i <= maxl; i++) { if (!notprime[i]) prime[++tot] = i; for (int j = 1;...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 3e5 + 10; int flag[N]; set<int> s[N]; int a[N]; int pos[N]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); pos[a[i]] = i; } while (...
#include <bits/stdc++.h> using namespace std; const int _1e5 = 100000; const int _1e7 = 10000000; const int _1e9 = 1000000000; template <typename A, typename B> ostream& operator<<(ostream& str, const pair<A, B>& p) { return str << ( << p.first << , << p.second << ) ; } template <typename T> ...
#include <bits/stdc++.h> char chars[200005]; int main() { int n; scanf( %d , &n); scanf( %s , chars); int sum = 0; for (int i = 0; i < n; i++) { if (chars[i] == < ) { sum++; } else { break; } } for (int i = n - 1; i >= 0 && sum < n; i--) { if (cha...
`timescale 1 ns / 1 ps module axis_measure_pulse # ( parameter integer AXIS_TDATA_WIDTH = 16, parameter integer CNTR_WIDTH = 16, parameter integer PULSE_WIDTH = 16, parameter integer BRAM_DATA_WIDTH = 16, parameter integer BRAM_ADDR_WIDTH = 16 ) ( // System signals input wire acl...
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; int x = 0, y = 0, z = 0; for (int i = 0; i < a.length(); i++) { if (a[i] != b[i]) { if (a[i] == 4 ) x++; else y++; } } cout << min(x, y) + abs(x - y); } ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n; cin >> n; vector<long long int> arr; long long int num; for (int i = 0; i < n; i++) { cin >> num; arr.push_back(num); } sort(arr.begin(), a...
#include <bits/stdc++.h> using namespace std; char s[2002000], t[2002000]; int n; int a = 0, b = 0, c = 0, d = 0; int main() { cin >> n >> s >> t; for (int i = 0; i < 2 * n; i++) { if (s[i] == 1 && t[i] == 1 ) a++; else if (s[i] == 1 ) b++; else if (t[i] == 1 ) ...
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } return...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in ...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void in(long long int *a, long long int n) { for (long long int i = 0; i < n; i++) { cin >> a[i]; } } void out(long long int *a, long long int n) { for...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; if (n % 2 == 0) { cout << NO << endl; return 0; } cout << YES << endl; int arr[2 * n + 5]; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; string s; while (1) { if (n % 7 == 0) { n = n / 7; for (long long i = 0; i < n; i++) s.push_back( 7 ); break; } else { i...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2014.4 // Copyright (C) 2014 Xilinx Inc. All rights reserved. // // ============================================================== `timescale 1 ns / 1 ps m...
#include <bits/stdc++.h> using namespace std; const int MOD(1000000007); const int INF((1 << 30) - 1); const int MAXN(30); string a[MAXN]; int type[200] = {0}; int main() { int n, m, x; scanf( %d%d%d , &n, &m, &x); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = A ; i <= Z ; i++) t...
#include <bits/stdc++.h> using namespace std; template <typename T> void gmin(T &a, T b) { a = a < b ? a : b; } template <typename T> void gmax(T &a, T b) { a = a > b ? a : b; } const int MAXV = 410; const int MAXE = 1650; const int INF = 0x3f3f3f3f; struct Edge { int to, cap, nxt, cos...
#include <bits/stdc++.h> using namespace std; std::vector<long long> a; long long sm = 0; long long n, m; bool doo(long long x) { long long res = 0; for (long long i = 0; i < x; ++i) { res += a[i]; long long k = i + x; long long count = 1; while (k < n and a[k] - count > 0) { ...
#include <bits/stdc++.h> using namespace std; int n, mn = 200, c = 0, x, y, i; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> x >> y; mn = min(mn, y); c += x * mn; } cout << c; }
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) using namespace std; template <typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; } template <type...
/* lab4_part4.v - 50 Mhz Clock * * Copyright (c) 2014, Artem Tovbin <arty99 at gmail dot com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const long long MAX = 100005; const long double PI = 3.14159265359; const long double G = 9.807; const long long INF = 1e18; const long double EPS = 1e-6; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : ...
#include <bits/stdc++.h> using lint = long long; using ld = long double; template <class T> using numr = std::numeric_limits<T>; struct input_t { template <class T> operator T() { T t; std::cin >> t; return t; } } input; namespace ns { using namespace std; template <int m...
#include <bits/stdc++.h> using namespace std; int c1, c2, c3, c4, n, m; const int maxn = 1050; int a[maxn], b[maxn]; int p, q, r, s; int x, y; int main() { cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; x += min(c1 * a[i], c2); } for ...
#include <bits/stdc++.h> using namespace std; int main() { char str[25]; gets(str); int let[26]; for (int i = 0; i < 26; i++) { let[i] = 0; } int len = 0; for (int i = 0; str[i]; i++) { let[str[i] - a ]++; len++; } long long c = 0; for (int i = 0; i < 26; i...
//================================================================================================== // Filename : antares_divider.v // Created On : Thu Sep 3 08:41:07 2015 // Last Modified : Sat Nov 07 12:01:42 2015 // Revision : 1.0 // Author : Angel Terrones // Company : Universidad ...
//Legal Notice: (C)2016 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Tue May 09 02:07:22 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; int main() { int x; while (cin >> x) { map<char, int> p1; string str, strr; ; bool l = 0; int sum; cin >> str; for (int i = 0; i < str.size(); i++) { p1[str[i]]++; } for (int i = 0; i < str.size(); i+...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code ...
//---------------------------------------------------------------------------- // Copyright (C) 2001 Authors // // This source file may be used and distributed without restriction provided // that this copyright statement is not removed from the file and that any // derivative work contains the original copyright notic...
/////////////////////////////////////////////////////////////////////////////// // vim:set shiftwidth=3 softtabstop=3 expandtab: // // Module: jtag_bus.v // Project: NF2 (NF2 Control Network FPGA) // Description: NF2/CPCI bus interface. // // Provides synchronization logic for CPCI reg...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 6; const long long MOD = 1e9 + 7; int par[MAX]; long long sz[MAX]; long long triplets(long long x) { return x * (x - 1) * (x - 2); } bool isLucky(long long x) { while (x) { if (x % 10 != 4 and x % 10 != 7) return false; x ...
#include <bits/stdc++.h> using namespace std; struct ee { int d; int y; }; ee e[120]; ee r[1200]; bool ok(ee a, ee b) { return a.y > b.y; } int main() { int n; int k; while (cin >> n >> k) { memset(e, 0, sizeof(e)); memset(r, 0, sizeof(r)); for (int i = 0; i < n; i++)...
#include <bits/stdc++.h> using namespace std; const int MAXN = 5000; int p[MAXN], size[MAXN], n, m; int find_set(int v) { return v == p[v] ? v : p[v] = find_set(p[v]); } void union_set(int x, int y) { x = find_set(x); y = find_set(y); if (x != y) { if (size[x] < size[y]) swap(x, y); p[...
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const long long ooo = 9223372036854775807ll; const int _cnt = 1000 * 1000 + 7; const int _p = 1000 * 1000 * 1000 + 7; const int N = 1001005; const double PI = acos(-1.0); const double eps = 1e-9; int o(int x) { return x % _p; } ...
#include <bits/stdc++.h> using namespace std; int n, m; char mat[100][100]; char c; vector<int> us; int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> mat[i]; for (int i = 0; i < n; i++) { us.clear(); for (int j = 0; j < m; j++) { if (mat[i][j] == # ) us.push_bac...
#include <bits/stdc++.h> using namespace std; int main() { long long i, t, n, m, c, d, a[100005]; cin >> n >> m; if (n == 1 && m == 0) { cout << 10000000; return 0; } if (m < n / 2 || n < 2) { cout << -1; return 0; } c = 1000000000LL; for (int i = n - 1; i > 1...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
//***************************************************************************** // (c) Copyright 2008 - 2010 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property /...
#include <bits/stdc++.h> using namespace std; bool debug = false; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; map<string, int> lesha; vector<int> v; int nxt[500035][16], sz, w[1 << 15][16]; const int maxk = 110; int dp[1 << 15][maxk]; void ii() { for (int s = 0; s < (1 << n); ...
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, m, i, j, k, sum; long long int a[100001]; cin >> n >> k; bool yo = false; for (i = 1; i <= k; i++) cin >> a[i]; sum = LONG_LONG_MAX; for (i = 1; i <= k; i++) { if (n % a[i] < sum) { sum = n % a[i...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 9; long long Pow(long long a, long long x) { long long res = 1; while (x) { if (x & 1) res = res * a % mod; a = a * a % mod; x >>= 1; } return res; } long long inv(long long a) { return Pow(a, mod - 2);...
#include <bits/stdc++.h> using namespace std; int INF = 1000000007; string s; int n, k, c, v, ans; int fat[1000100], siz[1000100]; vector<int> edge[1000100]; struct node { int l, r, xo; node(int _l = 0, int _r = 0, int _xo = 0) : l(_l), r(_r), xo(_xo) {} int get() { return min(l, r); } voi...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = int(1e9); const int MAX = 200; int num[MAX], mixt[MAX]; int n; bool substring(string &a, string &b) { for (int i = 0; i < n; i++) { bool found = true; for (int j = 0; j < 3; j++) { if (a[i + j...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; int main() { int M[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cin >> M[i][j]; } } for (int i = 0; i < 3; i++) { int c = 0; for (int j = 0; j < 3; j++) { c = (i > 0 ? M[i - 1][j] : 0); ...
module NEURAL_LAYER_TEST; reg [16:1] A,B,cAA,cAB,cBA,cBB,b1,b2; wire [16:1] o1,o2; NEURAL_LAYER nl(A,B,cAA,cAB,cBA,cBB,b1,b2,o1,o2); initial begin $dumpfile("neural_layer_test.vcd"); $dumpvars(0,NEURAL_LAYER_TEST); $monitor ( "%t: A=%04x B=%04x cAA=%04x cAB=%04x cBA=%04x cBB=%04x b1=%04x b2=%04x o...
module host_interface ( //OUTPUTS output [31:0] HRDATA, output HREADYOUT, output HRESP, output [31:0] bus_wr, output [ 1:0] crc_poly_size, output [ 1:0] bus_size, output [ 1:0] rev_in_type, output rev_out_type, output crc_init_en, output crc_idr_en, output crc_poly_en, output buffer_write_en, output reset...
#include <bits/stdc++.h> using namespace std; char x[55]; int swim(char *c = x, int res = 0, int round = 0) { int l = strlen(c); if (round == 2) { if (l == 0 || l > 7 || (c[0] == 0 && l > 1)) return -1; int ba2y; sscanf(c, %d , &ba2y); if (ba2y > 1000000) return -1; return...
#include <bits/stdc++.h> using namespace std; const int maxN(2e5 + 10); typedef int i_N[maxN]; int N, K; namespace graph { i_N A, P, is_us, Cus, deg; pair<int, int> edge[maxN]; vector<int> adj[maxN], node[maxN]; void link(const int u, const int v) { adj[u].push_back(v); } void dfs(const int u) { ...