Submission #473257

# Submission time Handle Problem Language Result Execution time Memory
473257 2021-09-15T10:59:21 Z Mr_Ph Garaža (COCI17_garaza) C++14
0 / 160
4000 ms 4256 KB
///made by : Mr_Ph :D
#include<bits/stdc++.h>
#include<unordered_map>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
const double PI=acos(-1.0);
const ll mod=(ll)1e9+7;
//int dx[4] = {0, 0, 1, -1};
//int dy[4] = {1, -1, 0, 0};
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
///the end of the defines ;)
void solve()
{
    int n,q;
    cin>>n>>q;
    vll arr(n);
    ent(arr);
    vector<pair<ll,ll>>arr1;
    ll y=0;
    while(q--)
    {
        int x;
        cin>>x;
        if(x==1)
        {
            ll e,w;
            cin>>e>>w;
            e--;
            arr[e]=w;
        }
        else
        {
            // int cnt=0;
            int l,r;
            cin>>l>>r;
            l--,r--;
            arr1.push_back({l,r});
        }
    }
    for(int i=0; i<arr1.sz; i++)
    {
        int cnt=0;
        int l=arr1[i].first,r=arr1[i].second;
        for(int i=l; i<=r; i++)
        {
            y=0;
            for(int k=i; k<=r; k++)
            {
                y=__gcd(y,arr[k]);
                if(y>1)
                    cnt++;
            }
        }
        cout<<cnt<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    //freopen("window.in","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;//int st;
    //cin>>t;//cin>>st;
    while(t--)
        solve();
}

Compilation message

garaza.cpp: In function 'void solve()':
garaza.cpp:18:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
      |                              ~^~~~~~~~~~~
garaza.cpp:28:5: note: in expansion of macro 'ent'
   28 |     ent(arr);
      |     ^~~
garaza.cpp:51:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i=0; i<arr1.sz; i++)
      |                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 648 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 1872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4066 ms 4256 KB Time limit exceeded
2 Halted 0 ms 0 KB -