Common BoardFew lines of code with no conditions The most time I consumed was to prove that naive algorithm works here :) 4 WMC WMC WMC WMC --- 3 Looking for rogue 4 WM WMC WMR MR --- 4 Okey, he lost the page that had the number of the k-th interesting lamppost. So, the input contains one integer k. > Output the number of the k-th interesting lamppost. Sorry, what? What does input `k` mean then? ____ Я вроде бы родился русским, но никак не могу понять условие задачи. Это что, часть задачи - понять что требуется? Да, так и есть. По входным данным надо было понять, что это алгебраческая прогрессия, с шагом в 10074. same use sets it's easy with them Сначала пробовал через множества, потом сократил через map всегда валился на 8 тесте по времени Решил напрячься Сел и написал два модуля, чтобы работать с битами На преподавателе включаю биты На студенте проверяю и прибавляю к ответу Сдаю задачу, уже в предвкушении надписи "Accepted", как тут мои глаза лезут на лоб. Снова "TL8" Что это за монстр такой этот восьмой тест?) Обычный бинарный поиск в этой задаче же. #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n--){ string s; int a,b; cin>>s; a = s[0]-'a'+1; b = s[1]-'0'; a = min(a,9-a); b = min(b,9-b); if(a==b){ if(a==1) printf("2\n"); else if(a==2) printf("4\n"); else printf("8\n"); } else { if((a==1&&b==2)||(a==2&&b==1)) printf("3\n"); else if((a==1&&b>=3)||(a>=3&&b==1)) printf("4\n"); else if((a==2&&b>=3)||(a>=3&&b==2)) printf("6\n"); else if(a>2&&b>2)printf("8\n"); } } return 0; } I am stuck with this, it seems impossible to value from input to 2 registers. Ok, you can actually read n from input multiple times. And you can reduce value in current register to zero while increasing 2 (or more) other registers. This leads to copy operation. What is this test about? My limit was 10^4, not 10^5 Wrong answer 18. Can anybody help me, please? В задаче сказано, проверить существует ли такая команда 'x' что она обыграет и команду A и команду В, если существует то ответ No иначе YES в таком случае можно использовать bitset Who many test???????????????????? ??0??1 ?0000? the answer is: 000001 000001 I'm also hung in testcase 53,who can help me?both test data or thought is ok. I defined three functions: C(i) - the number of ways to make the album if it consists of only i songs. A(i) - the number of ways ending in 1. B(i) - the number of ways ending in 2. C(i) = A(i) + B(i) A(i) = 1 if i <= 1 = C(i-1) if 1< i <=a = C(i-1) - B(i-a-1) i>a Notice that if i <= a there's no way to have more than a 1's, so we call C(i-1) and 'append' 1 at position i. The number of ways to do this reminds the same as C(i-1). If i>a you could have an invalid string of 1's. To counter this, we call B(i-a-1) to know exactly how many sequences would be invalid if we 'append' a 1 at position i. When i=a+1, there's only one invalid string resulting of appending 1 at a+1, the sequence consisting of only 1's. B is analogous to A (calls A instead of B and uses b instead of a). Edited by author 12.07.2019 04:31 But how do we eliminate duplicates ? ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ Answer: 36 Подумайте о типе графа, дерево #include <stdio.h> #include <math.h> int main() { int n; scanf("%d",&n); n=12-n; n>=7?printf("NO"):printf("YES"); return 0; } #include <stdio.h> int main(){ int n1,h,g; scanf ("%d",&n1); h=12-n1; g=h*45; if (g<=300){ printf ("YES");} else{ printf("NO");} return 0; }
/*In the name of Almighty Allah*/ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<string> vs; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef pair<int,int> pii; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; typedef set<int> si; typedef map<string,int> msi; typedef double dl; typedef string st; #define PB push_back #define F first #define S second #define MP make_pair #define endl '\n' #define all(a) (a).begin(),(a).end() #define sz(x) (int)x.size() #define mid(l,r) ((r+l)/2) #define left(node) (node*2) #define right(node) (node*2+1) #define mx_int_prime 999999937 #define CY cout<<"YES"<<endl #define CN cout<<"NO"<<endl #define rn return 0 const double PI = acos(-1); const double eps = 1e-9;//10^-9 const int inf = 2000000000; const ll infLL = 9000000000000000000; #define MOD 1000000007 #define PI 2*acos(0.0) #define mem(a,b) memset(a, b, sizeof(a) ) #define gcd(a,b) __gcd(a,b) #define sqr(a) ((a) * (a)) #define sw(a,b) swap(a,b) #define sor(a) sort(a.begin(),a.end()) #define sorr(a) sort(a.begin(),a.end(),greater<int>()) #define uni(s) unique(s.begin(),s.end())-s.begin() #define mxdex(a) max_element(v.begin(),v.end())-v.begin() #define mindex(a) min_element(v.begin(),v.end())-v.begin() #define mxele(a) max_element(v.begin(),v.end()) #define minele(a) min_element(v.begin(),v.end()) #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define fraction(a) cout.unsetf(ios::floatfield); cout.precision(a); cout.setf(ios::fixed,ios::floatfield); #define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); typedef vector<int>::iterator vit; typedef set<int>::iterator sit; int dx[] = {0, 0, +1, -1}; int dy[] = {+1, -1, 0, 0}; //int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1}; //int dy[] = {0, +1, 0, -1, +1, -1, +1, -1}; //Debugger template < typename F, typename S > ostream& operator << ( ostream& os, const pair< F, S > & p ) { return os << "(" << p.first << ", " << p.second << ")"; } template < typename T > ostream &operator << ( ostream & os, const vector< T > &v ) { os << "{"; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << *it; } return os << "}"; } template < typename T > ostream &operator << ( ostream & os, const set< T > &v ) { os << "["; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << *it; } return os << "]"; } template < typename T > ostream &operator << ( ostream & os, const multiset< T > &v ) { os << "["; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << *it; } return os << "]"; } template < typename F, typename S > ostream &operator << ( ostream & os, const map< F, S > &v ) { os << "["; for(auto it = v.begin(); it != v.end(); ++it) { if( it != v.begin() ) os << ", "; os << it -> first << " = " << it -> second ; } return os << "]"; } #define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0) void faltu () { cerr << endl; } template <typename T> void faltu( T a[], int n ) { for(int i = 0; i < n; ++i) cerr << a[i] << ' '; cerr << endl; } template <typename T, typename ... hello> void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); } int main() { optimize(); int f; cin>>f; int x=240/(12-f); if(x<45) CN; else CY; rn; } Edited by author 17.01.2021 23:37 check the values of y[i] by x[i] - x[i-1] in the straight line equation > > > > > > > > use ceil() and floor() |
|