제출 #1020266

#제출 시각아이디문제언어결과실행 시간메모리
1020266cpptowinIntercastellar (JOI22_ho_t1)C++17
100 / 100
48 ms7764 KiB
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i = l ;i <= r ; i++)
#define fod(i,r,l) for(int i = r ; i >= l ; i--)
#define int long long
#define pb emplace_back
#define maxn 1000010
#define fi first
#define se second
#define N 1010
#define inf (int)1e18
#define en cout << "\n";
#define all(x) x.begin(),x.end()
#define ss(x) (int)x.size()
#define lb(x) x & -x
#define bit(x,i) ((x >> i) & 1)
#define onbit(x,i) (x | (1ll << i))
#define offbit(x,i) (x ^ (1ll << i))
#define bitcount(x) __builtint_popcountll(x)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
using namespace std;
int n,a[maxn];
main()
{
    #define name "TASK"
    if(fopen(name".inp","r"))
    {
        freopen(name".inp","r",stdin);
        freopen(name".out","w",stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    fo(i,1,n) cin >> a[i];
    int q;cin >> q;
    int pos = 0,i = 1;
    while(q--)
    {
        int x;
        cin >> x;
        while(pos < x)
        {
            int cnt = 1;
            while(a[i] % 2 == 0)
            {
                a[i] /= 2;
                cnt *= 2;
            }
            pos += cnt;
            i++;
        }
        cout << a[i - 1] << "\n";
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   24 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(name".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(name".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...