?
№ | Отправитель | Задача | Язык | Вердикт | Время | Память | Отослано | Протест. | |
---|---|---|---|---|---|---|---|---|---|
103369673 |
Дорешивание: hackerakhil |
1468C - 34 | C++14 (GCC 6-32) | Превышено ограничение времени на тесте 12 | 5000 мс | 1052 КБ | 2021-01-05 13:38:39 | 2021-01-05 13:38:39 |
#include <bits/stdc++.h> #include <algorithm> //#include <boost/lexical_cast.hpp>// for lexical_cast() #include <string> // for string using namespace std; #define int long long #define all(container) container.begin(), container.end() #define tr(container, it) \ for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) const int MOD = 1e9+7; bool isPrime(int n) { // Corner cases if (n <= 1) return false; if (n <= 3) return true; // This is checked so that we can skip // middle five numbers in below loop if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } //modular and binary exponentiation power Function int power(int a, int b) { if(a==0) return 0; int res=1; // if(a>=p) // a = a%p; while(b>0) { if(b&1) res=(res*a); b>>=1; a=(a*a); } return res; } // Function that convert Decimal to binary vector<int> decToBinary(int n) { // Size of an integer is assumed to be 32 bits vector<int> v; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) v.push_back(1); else v.push_back(0); } return v; } int binarySearch(int arr[], int l, int r, int x) { if (r >= l) { int mid = l + (r - l) / 2; // If the element is present at the middle // itself if (arr[mid] == x) return mid; // If element is smaller than mid, then // it can only be present in left subarray if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); // Else the element can only be present // in right subarray return binarySearch(arr, mid + 1, r, x); } // We reach here when element is not // present in array return -1; } int maxResult(int n, int a, int b, int c) { int maxVal = 0; // i represents possible values of a * x for (int i = 0; i <= n; i += a) // j represents possible values of b * y for (int j = 0; j <= n - i; j += b) { float z = (float) (n - (i + j)) / c; // If z is an integer if (floor(z) == ceil(z)) { int x = i / a; int y = j / b; maxVal = max(maxVal, x + y + (int)z); } } return maxVal; } bool binary_search_vector(const vector<int>& sorted_vec, int key) { size_t mid, left = 0 ; size_t right = sorted_vec.size(); // one position passed the right end while (left < right) { mid = left + (right - left)/2; if (key > sorted_vec[mid]){ left = mid+1; } else if (key < sorted_vec[mid]){ right = mid; } else { return true; } } return false; } void SeiveOfEratosthenes(int n,int k) { bool prime[n+1]; vector<int> v; memset(prime,true,sizeof(prime)); for(int i=2;i*i<=n;i++) { if(prime[i]) { for(int j=i*i;j<=n;j+=i) { prime[j] = false; } } } for(int i=2;i<=n;i++) { if(prime[i]) { v.push_back(i); } } } int gcd(int a, int b) { if(a == 0) return b; return gcd(b % a, a); } int ind = 0; vector< pair<int,int> > v; // Driver function to sort the vector elements // by second element of pairs bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); } bool sortbysec1(const pair<int,int> &a, const pair<int,int> &b) { if(a.first == b.first) return (a.second < b.second); else return (a.first>b.first); } void solve() { int x; cin>>x; if(x==1) { ind++; int m; cin>>m; // cout<<m<<" "; v.push_back({m,ind}); // cout<<u[0].first<<" "<<v[0].first; } if(x==2) { sort(v.begin(),v.end(),sortbysec); cout<<v[0].second; v.erase(v.begin() + 0); cout<<"\n"; } if(x==3) { sort(v.begin(), v.end(),sortbysec1); cout<<v[0].second; v.erase(v.begin() + 0 ); cout<<"\n"; } //cout<<"EDF"<<" "; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin>>t; while(t--) { solve(); } }
?
?
?
?