Common BoardIt must be mentioned that two dice are considered equal if the numbers of points on corresponding faces are equal regardless of the orientation of the points on each face. For example, if you superimpose two dice and the numbers of points coincide but two corresponding faces look like this: #.. ..# .#. and .#. ..# #.. then the dice have the same schemes. Edited by author 09.06.2018 22:36 import java.util.*; import java.lang.*; public class Factorial{ public static void main(String[] args){ Scanner cin=new Scanner(System.in); int n=Integer.parseInt(cin.next()); String k=cin.nextLine(); int j=k.length()-1; int sum=1; for(int i=n;i>0;i-=j){ sum=sum*i; } System.out.println(sum); } } #include <stdio.h> void main() { int N,i,sum; sum = 0; scanf_s("%d", &N); if (N < 0) { for (i = N; i < 2; i++) { sum = sum + i; } } else { for (i = N; i > 0; i--) { sum = sum + i; } } printf("%d", sum);
} I cant understand my mistake for TLE14. My code var s,s1,s2: string; z2,z1,a,i,f,p,code: integer;z,n:int64; ch:char; begin readln(s); readln(npalindrome? 1 100000); for i:=1 to n do begin readln(s2); if s2[1]='p' then begin a:=13;z1:=0;z2:=0; while s2[a]<>' ' do inc(a); val(copy(s2,13,a-13),z1,code); val(copy(s2,a+1,length(s2)-1),z2,code); z:=z2-z1+1; if z2>length(s) then z2:=length(s); s1:=copy(s,z1,z);
f := 1; p:=1; while (p<=length(s1)div 2)and(f<>0) do if (s1[p] <> s1[length(s1)-p+1]) then begin writeln('No'); f := 0; end else p:=p+1;
if f = 1 then writeln('Yes'); end else begin a:=8;z1:=0; while s2[a]<>' ' do inc(a); Val(copy(s2,8,a-8),z1,code); ch:=s2[a+1]; delete(s,z1,1); insert(ch,s,z1);
end; end; end. Check that arrays were initiated with zeroes. unfortunately it didn't help. //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; const int maxn = (int) 1e5; int a[maxn]; int main() { int n, x; cin >> n; fo(i, n) { cin >> a[i]; } sort(a, a + n); string str; cin >> str >> n; fo(i, n) { cin >> x; cout << a[x - 1] << '\n'; } re 0; } package timusreverseroot; import java.text.DecimalFormat; import java.util.*; public class TimusReverseRoot { public static void main(String[] args) { DecimalFormat f = new DecimalFormat("#0.0000"); Scanner keyboard = new Scanner(System.in); String inputs = keyboard.nextLine(); String[] parsed = inputs.split(" ");
for (String parsed1 : parsed) { int square = (int) Math.pow(Integer.parseInt(parsed1), 2); System.out.println(f.format(square)); } }
} I added in the package line but if I left that in, it would give me a compilation error, why is that? And this code runs perfectly fine in Netbeans but the judge gives a compilation error Edited by author 07.05.2018 22:48 Edited by author 07.05.2018 22:49 Edited by author 07.06.2018 01:49 //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; int main() { int n, x; ii ans = mp(-1, 0); pair <ii, int> cur; cin >> n >> cur.fi.fi; cur.fi.se = cur.se = 0; fo(i, n - 1) { cin >> x; if (x >= cur.fi.fi) ++cur.fi.se; else { cur.fi.se++; ans = max(ans, mp(cur.fi.se, cur.se)); cur = mp(mp(x, 1), i + 1); } } ans = max(ans, mp(cur.fi.se, cur.se)); cout << ans.se + 1 << endl; } //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; double calc () { int a, b; cin >> a >> b; if (a == 1) re b * 2; if (a == 2) re b; re sqrt(3) * b / 2.0; } int main() { int ans = 0, a, b; double fuck; cin >> a >> b; if (a == 1) fuck = b * 2; if (a == 2) fuck = b * sqrt(2); if (a == 3) fuck = b; int n; cin >> n; fo(i, n) { if (calc() <= fuck) ++ans; } cout << ans << endl; } //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; int main() { int n; cin >> n; vector <pair<ii, int>> v(n); fo(i, n) { cin >> v[i].fi.fi >> v[i].fi.se; v[i].se = i + 1; } sort(all(v)); for (int i = 0; i < n; i += 2) { cout << v[i].se << ' '<< v[i + 1].se << '\n'; } } I have got error so many times. Wonder wht I am missing.. Here is my Python 3.4 Code n,m=map(int,input().split()) g=list(map(int,input().split())) b=list(map(int,input().split())) g.sort() b.sort() minUpset=0 for i in range(0,n): minUpset+=g[i] for s in range(0,min(n,m)): girlsUpset=0 boysUpset=0 for i in range(0,n-s): girlsUpset+=g[i] for j in range(0,m-s): boysUpset+=b[j] minUpset=min(girlsUpset+boysUpset*s,minUpset) print(minUpset)
Found the mistake. Always need to test when use loop. for s in range(0, min(n, m) + 1) //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; const int maxn = 100; int a[maxn], b[maxn]; int main() { int n, m; cin >> n >> m; fo(i, n) cin >> a[i]; fo(i, m) cin >> b[i]; sort(a, a + n), sort(b, b + m); reverse(a, a + n), reverse(b, b + m); int ans = (int) 1e9, cur; fo(k, min(n, m) + 1) { cur = 0; for (int j = k; j < n; ++j) cur += a[j]; for (int j = k; j < m; ++j) cur += b[j] * k; ans = min (ans, cur); } cout << ans << endl; } //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; int calc () { string str; cin >> str; re (str[0] - '0') * 600 + (str[1] - '0') * 60 + stoi(str.substr(3, 2)); } int main() { int n1, n2, n3, c1, c2, t; cin >> n1 >> c1 >> n2 >> t >> c2 >> n3; int k, time; int ans = 0; cin >> k; while (k--) { time = calc(); if (time <= 6) continue; ans += (time + 59) / 60; } cout << "Basic: " << n1 + ans * c1 << endl; cout << "Combined: " << n2 + max(0, ans - t) * c2 << endl; cout << "Unlimited: " << n3 << endl; } n=100: 168 n=555: 984 n=1000: 1785 n=1100: 1963 n=2000: 3598 I solved the equation x(x-1) % 10^i = 0 for every i>1 and i<=n by linear algorithm, using roots for i-1. Test 2 is something like this 3 2 0 Good luck! Thank you very very much , I love u Thank you !!! you test help found my mistake i tested the answer is 500. it's right. but i still get WA 2 Use if(c> 8000000000LL || c< -8000000000LL) break ; this line in BInary search... code : [deleted] Edited by author 01.06.2018 17:02 Edited by moderator 20.11.2019 22:45 plz can someone give the 4th test Try the case when total time is less than prepayed time in 'Combined' rate. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp4 { class Program { static void Main(string[] args) { int n = Convert.ToInt16(Console.ReadLine()); int s = 2; for (int i = 1; i<=n; i++) { string a = Console.ReadLine(); if (a.Contains("+one")) s += 2; else s++; } if (s == 13) s++; Console.WriteLine(s * 100); } } } Did anybody get AC with the MaxFlow algorithm? Sure, why not? Push relabel algorithm got TL on test 30. Dinic with scaling got AC in 0.249 s. Interestingly, push-relabel algorithm (with some optimizations) that I used is usually a little bit faster than my Dinic with scaling. |
|