QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#724465#7660. Investigating Frog Behaviour on Lily Pad Patternsah_nafWA 1506ms128620kbC++144.1kb2024-11-08 13:16:382024-11-08 13:16:40

Judging History

This is the latest submission verdict.

  • [2024-11-08 13:16:40]
  • Judged
  • Verdict: WA
  • Time: 1506ms
  • Memory: 128620kb
  • [2024-11-08 13:16:38]
  • Submitted

answer

/*________________________Bismillahir Rahmanir Rahim___________________
|                                                                      |
|                    /\     |     | |\    |     /\     |-------        |
|                   /  \    |     | | \   |    /  \    |               |
|                  /----\   |-----| |  \  |   /----\   |-----          |
|                 /      \  |     | |   \ |  /      \  |               |
|                /        \ |     | |    \| /        \ |               |
|                                                                      |
|                    14th batch CSE , ID : 12008029                    |
|                          Comilla University                          |
|                    Email: [email protected]                |
|                    Github: https://github.com/ah-naf                 |
|______________________________________________________________________*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <string>
#include <iostream>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define MAX 2000005
#define pb push_back
#define mp make_pair
#define vii vector<int>
#define vll vector<long long>
#define vp vector<pair<ll, ll>>
#define v_min(a) *min_element(a.begin(), a.end())
#define v_max(a) *max_element(a.begin(), a.end())
#define v_sum(a) accumulate(a.begin(), a.end(), 0LL)
#define un(a) a.erase(unique(a.begin(), a.end()), a.end())
#define SORT(a) sort(a.begin(), a.end())
#define AHNAF                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b)) / gcd(a, b)
#define endl '\n'
#define YES cout << "Yes" << "\n"
#define NO cout << "No" << "\n"
#define testcase(t) \
    int t;          \
    cin >> t;       \
    while (t--)
#define reverse(a) reverse(a.begin(), a.end())
#define ff first
#define ss second
#define print(a)      \
    for (auto it: a) \
    cout << it << " "; \
    cout<<endl;
#define all(a) a.begin(), a.end()
#define sf(v)          \
    for (auto &it : v) \
    cin >> it

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
// const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
// const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------
bool checkbit(ll mask,int bit){return mask & (1LL<<bit);}
ll setbit(ll mask,int bit){ return mask | (1LL<<bit) ; }
ll clearbit(ll mask,int bit){return mask & ~(1LL<<bit);}
ll togglebit(ll mask,int bit){return mask ^ (1LL<<bit);}
//--------------------------------------------------------------//
 
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T, typename R> using ordered_map = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// cout << *se.find_by_order(0) << endl; ///k th element
// cout << se.order_of_key(2) << endl; ///number of elements less than k

const int N = 1e5 + 5;
const ll mod = 1e9 + 7;

void solve(int tc=1) {
    int n; cin>>n;
    ordered_set<double> s;
    for(int i=1; i<=2e6; i++) {
        s.insert((double)i);
    }
    vii v(n); sf(v);
    for(auto it: v) {
        s.erase(it);
    }
    // return;
    int q; cin>>q;
    while(q--) {
        int x; cin>>x;
        int aghe = s.order_of_key(x+0.1);
        int val = *s.find_by_order(aghe);
        // cout<<val<<endl;
        cout<<val<<endl;
        s.erase(val);
        s.insert(x);
    }
}

 
int main() {    
    AHNAF;
    // sieve();
    // phi_1_to_n();
    // prec();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);  
    #endif
    int tc=1;
    // cin>>tc; 
    for(int i=1; i<=tc; i++) solve(i);
    
}

详细

Test #1:

score: 100
Accepted
time: 1506ms
memory: 128620kb

input:

5
1 2 3 5 7
3
1
2
4

output:

4
6
8

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1300ms
memory: 128552kb

input:

5
1 2 3 5 7
4
1
1
1
1

output:

4
6
8
9

result:

ok 4 lines

Test #3:

score: -100
Wrong Answer
time: 1370ms
memory: 128540kb

input:

5
1 2 3 4 5
20
1
4
4
3
5
3
3
5
2
2
5
4
1
4
2
3
1
5
3
3

output:

6
7
8
4
9
5
10
11
3
5
12
5
2
13
4
14
2
15
5
16

result:

wrong answer 5th lines differ - expected: '7', found: '9'