Блог пользователя darkrace

Автор darkrace, 10 лет назад, По-английски

hii everyone..i am new here...wer can i ask doubts regarding any problems??i am not seeing any active dicussion about problems.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
10 лет назад, # |
Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

You can ask them just in these posts — it is the most usual way. However try to respect English language to increase chance of being answered, instead of being severely downvoted ;-)

»
10 лет назад, # |
  Проголосовать: нравится -46 Проголосовать: не нравится

You are not only new, you are also very stupid.

»
10 лет назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

Each problem here was a part of contest. When you solve a problem , see the tutorial , probably you will find some contestants who was discussing these problems after each contest. And as RodionGork said , try to respect English language to increase chance of being answered. Welcome to Codeforces =)

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

As Druid mentioned you can always look up the tutorial for a problem that was in a competition here, but you can also always ask any questions about any problems you encounter at all, in just these posts (blogs). Codeforces community is friendly and helpful, I have asked questions myself and someone always had the right answer, so if there is any task you are struggling with you can always ask here for help. As previously mentioned, try describing the problem you have in proper English so people can understand and help you (it also irritates a lot of people when they see posts with bad English), and I'm sure you will get the answers you are looking for.

Welcome to Codeforces! :)

»
3 года назад, # |
  Проголосовать: нравится -6 Проголосовать: не нравится

What is the means of this in any program #define mod 998244353

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    if you want to use the value 998244353 anywhere in your code you can write mod instead of writing 998244353.

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится +5 Проголосовать: не нравится

      Like helping someone is a crime here.Why down-votes?

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      You will have to define this value as mod you cannot use it otherwise as per my knowledge

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        No, "mod" is just a name given to that number, you can name it anything you like. As #define is a preprocessor command, so every instance of "mod" will be replaced by 998244353 before compiling.

        • »
          »
          »
          »
          »
          3 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          That's what I was saying that you will have to define it using #define mod 998244353 or you can use it like int mod=998244353

»
3 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

What is the different between 1. v.push_back({v[i].first, v[i].second + 1}); Vs 2. v.push_back((v[i].first, v[i].second + 1));

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +25 Проголосовать: не нравится
    1. Inserts a pair in a vector
    2. Throws an error
  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится
    1. is wrong, an alternative that is right is
     v.push_back(make_pair(v[i].first, v[i].second + 1));
    

    Edit- I know 1 is not wrong, 2 is wrong, but somehow idk how to fix it, see my reply below for more context

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      1 isn't wrong. The following works fine.

      Spoiler
      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится +11 Проголосовать: не нравится

        Yeah, ur right, I know 1 works which is why I thought i had mistyped it but infact i had written it correctly and cf somehow changed it, idk This link will explain better . Am i missing something obvious here?

        • »
          »
          »
          »
          »
          3 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          that's funny, I think it got confused with markdown for a numbered list and those forcibly start at 1

        • »
          »
          »
          »
          »
          3 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          I played around with it a bit. Looks like it's treating 2. as the start of a list and substituting the html with a list wrapper. Seems to cause the same result whenever you put a number followed by a . on a new line followed by some text. 255. a becomes.

          1. a
  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    Or you could also use: v.emplace_back(v[i].first, v[i].second + 1)

»
4 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

20C][SUBMISSION:239959904 - Dijkstra? please see fails on large test case test case 31 failed. Dijkstra 20c <-problem


#include <iostream> #include <bits/stdc++.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <unordered_map> #include <deque> #include <list> using namespace std; #define ull unsigned long long #define ll long long #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL) #define readi(x) ull x;cin>>x #include<bits/stdc++.h> using namespace std; void ulp(int node, vector<int>&parent, vector<int>&ans) { if (parent[node] == node) { ans.push_back(node); return; } ans.push_back(node); ulp(parent[node], parent, ans); } void dij(vector<vector<int>>edges, int V) { vector<pair<int, int>>adj[V + 1]; for (auto it : edges) { int u = it[0]; int v = it[1]; int wt = it[2]; adj[u].push_back({v, wt}); adj[v].push_back({u, wt}); } priority_queue < pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq; pq.push({0, 1}); vector<int>dist(V + 1, 1e9); vector<int>parent(V + 1); for (int i = 0; i <= V; i++)parent[i] = i; dist[1] = 0; while (!pq.empty()) { auto it = pq.top(); pq.pop(); int wt = it.first; int node = it.second; for (auto it : adj[node]) { int adjNode = it.first; int adjWt = it.second; if (wt + adjWt < dist[adjNode]) { parent[adjNode] = node; dist[adjNode] = wt + adjWt; pq.push({dist[adjNode], adjNode}); } } } if (dist[V] == 1e9) { cout << -1 << endl; return; } vector<int>ans; ulp(V, parent, ans); reverse(ans.begin(), ans.end()); for (auto it : ans)cout << it << " "; } int main() { //uncomment the below for USACO Submission and name the problem name.in etc etc. read more->https://codeforces.com/blog/entry/84772 // if (fopen("perimeter.in", "r")) { // freopen("perimeter.in", "r", stdin); // freopen("perimeter.out", "w", stdout); // } fast_io; #ifndef ONLINE_JUDGE freopen("INPUT.txt", "r", stdin); freopen("Op.txt", "w", stdout); #endif int n, m; cin >> n >> m; vector<vector<int>>edges; while (m--) { int a, b, w; cin >> a >> b >> w; edges.push_back({a, b, w}); } dij(edges, n); return 0; }
  • »
    »
    4 месяца назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Use long long or unsigned long long types instead of int type. ALSO USE ....king spoilers.

  • »
    »
    4 месяца назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    Here is the link with the corrected solution :"Link"

    • »
      »
      »
      4 месяца назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      [submission:239953552][submission:Codeforces Round 473 (Div. 2)] Can you please debug this snippet.test case 3 is failing. i have attached the image also.

      #include <iostream>
      #include <bits/stdc++.h>
      #include <algorithm>
      #include <vector>
      #include <queue>
      #include <set>
      #include <unordered_map>
      #include <deque>
      #include <list>
      using namespace std;
       
      #define ull unsigned long long
      #define ll long long
      #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
      #define readi(x) ull x;cin>>x
      //{ Driver Code Starts
      #include<bits/stdc++.h>
      using namespace std;
       
      
       
       
      class dsu {
      public:
      	vector<ull>size;
      	vector<ull>parent;
      	vector<ull>cost;
       
      	dsu(ull n, vector<ull>cst) {
      		size.resize(n + 1, 1);
      		parent.resize(n + 1);
      		cost.resize(n + 1);
      		for (ull i = 0; i <= n; i++)parent[i] = i;
      		for (ull i = 1; i <= n; i++) {
      			cost[i] = cst[i - 1];
      		}
      	}
      	ull findParent(ull node) {
      		if (parent[node] == node)return node;
      		return parent[node] = findParent(parent[node]);
      	}
       
      	void unionBySize(ull u, ull v) {
      		ull ulp_u = findParent(u);
      		ull ulp_v = findParent(v);
       
      		if (ulp_u == ulp_v)return ;
      		else if (size[ulp_u] < size[ulp_v]) {
      			parent[ulp_u] = ulp_v;
      			size[ulp_v] += size[ulp_u];
      			cost[ulp_u] = min(cost[ulp_u], cost[ulp_v]);
       
      		}
      		else {
      			parent[ulp_v] = ulp_u;
      			size[ulp_u] += size[ulp_v];
      			cost[ulp_v] = min(cost[ulp_u], cost[ulp_v]);
       
      		}
      	}
       
       
       
      };
       
       
      void solve(vector<string>&words,
                 vector<ull>&cost,
                 vector<vector<ull>>&same,
                 vector<string>&message) {
       
      	unordered_map<string, ull>mp;
      	unordered_map<string, ull>mp2;
      	for (ull i = 0; i < words.size(); i++) {
      		mp2[words[i]] = cost[i];
      	}
      	for (ull i = 0; i < words.size(); i++) {
      		mp[words[i]] = i + 1;
      	}
       
      	dsu ds(words.size(), cost);
       
       
       
       
      	for (ull i = 0; i < same.size(); i++) {
      		for (ull j = 0; j < same[i].size() - 1; j++) {
      			ds.unionBySize(same[i][j], same[i][j + 1]);
      		}
      	}
       
       
       
       
      	ull ans1 = 0;
      	ull ans2 = 0;
       
       
       
       
      	for (auto it : message) {
      		ans1 += mp2[it];
      	}
       
      	for (auto it : message) {
      		ans2 += ds.cost[ds.findParent(mp[it])];
      	}
       
      	cout << min(ans1, ans2) << endl;
       
       
       
       
       
       
       
       
       
      	return;
      }
       
      int main() {
      	//uncomment the below for USACO Submission and name the problem name.in etc etc. read more->https://codeforces.com/blog/entry/84772
       
      	// if (fopen("perimeter.in", "r")) {
      	// 	freopen("perimeter.in", "r", stdin);
      	// 	freopen("perimeter.out", "w", stdout);
      	// }
       
      	fast_io;
      #ifndef ONLINE_JUDGE
      	freopen("INPUT.txt", "r", stdin);
      	freopen("Op.txt", "w", stdout);
      #endif
       
       
       
      	ull n, k, m;
      	cin >> n >> k >> m;
      	vector<string>words(n);
      	vector<ull>cost(n);
      	vector<vector<ull>>same;
      	vector<string>message(m);
      	for (ull i = 0; i < n; i++)cin >> words[i];
      	for (ull i = 0; i < n; i++)cin >> cost[i];
       
      	for (ull i = 0; i < k; i++) {
      		vector<ull>temp;
      		ull nm;
      		cin >> nm;
      		while (nm--) {
      			ull a;
      			cin >> a;
      			temp.push_back(a);
      		}
      		same.push_back(temp);
      	}
       
      	for (ull i = 0; i < m; ++i)cin >> message[i];
       
      	solve(words, cost, same, message);
      	return 0;
      }
       
      
      • »
        »
        »
        »
        4 месяца назад, # ^ |
        Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

        Your error was in the UnionBySize function .Here is the corrected solution:"Link. "

        You mixed up the lines: "cost[ulp_u] = min(cost[ulp_u], cost[ulp_v]) with ; cost[ulp_v] = min(cost[ulp_u], cost[ulp_v]);"

»
3 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

please guide me which of the following topics are important for Competitive programming. also if you can share some of the problems/links related to the following topics in mathematics:

Root finding for non linear equations and systems of equation

1 Introduction to Numerical computations and floating point arithmetic

2 Types of errors, significant digits and error propagation.

3 Introduction to iterative methods, initial approximation and intermediate value theorem

4 Iterative Methods based on first degree equation

5 Iterative Methods based on second degree equation: Muller Method

6 Solved Problems using Muller Method

7 Chebyshev Method

8 Solution of the system of non-linear equations using the Newton Raphson method.

** Interpolation**

11 Finite Difference Operators

12 Interpolating polynomials using Finite Difference(Gauss Forward)

13 Interpolating polynomials using Finite Difference(Gauss Backward)

14 Hermite Interpolation

15 Problem solving

16 Tutorial(Problem Solving)

17 Lagrange Bivariate Interpolation

18 Newton’s Bivariate Interpolation for Equispaced Points

19 Inverse Interpolation

Numerical Integration

21 Introduction to Numerical Integration

22 Numerical Integration with known nodes

23 Rombergh Integration

24 Gauss-Legendre Integration

25 Gauss-Chebyshev

26 Gauss-Laguerre and Gauss-Hermite Integration Methods.

27 Problem solving

28 Double Integration by Trapizoidal methods.

29 Double Integration by Simpsons’ methods.

30 Problem solving Numerical Solution of ODEs and PDEs

32 Introduction to the numerical solution of ODEs

33 Initial Value Problems and it’s numerical solutions

34 Milne’s method

35 Boundary Value Problems using Shooting Method

36 Problem Solving

37 Finite Difference approximation of derivatives

38 Using Finite difference methods to solve 1D heat equation using explicitn method(Schmidt Method)

39 Finite difference methods to solve 1Dheat equation using implicit scheme(Crank Nicholson Method)

»
3 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

i don't get it how do i do it without using arithmetic operations please help!!

Problem Statement:

Given 'd' you have to calculate f(d) where , f(d)=2*d(d+1)+1 using bit manipulation. Dont't use +,-,/,* arithmetic operations either. f(d) is only for reference for checking for given d whether f(d) is valid or not.

constraints: 0<=d<=100, 1<=f(d)<=20201

test case1 d=0 op=1; test case2 d=1 op=5; test case3 d=2 op=13 test case4 d=3 op=25 test case5 d=4 op=41

int function(int d){

//don't do -> return 2*d(d+1)+1 instead try to do it using bit manipulation on given 'd' parameter.

}