QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#46587#1956. Find The Housemeomeo#WA 2ms3768kbC++978b2022-08-30 14:41:082022-08-30 14:41:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-30 14:41:09]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3768kb
  • [2022-08-30 14:41:08]
  • 提交

answer

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>,
rb_tree_tag,tree_order_statistics_node_update>;


signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
//    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n;

    while (cin >> n) {
        if (n == 0) {
            break;
        }

        map<int, int> a;

        for (int i = 0 ; i < n ; i++) {
            int pos;
            char t;
            int d;

            cin >> pos >> t >> d;

            if (t == 'L') {
                d *= -1;
            }

            a[pos] = pos + d;
        }

        int pos = 0;

        while (a.find(pos) != a.end()) {
            pos = a[pos];
        }

        cout << pos << "\n";
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3768kb

input:

4
3 R 4
-2 R 5
7 L 5
0 L 2
0

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3664kb

input:

5
10 L 7
1 R 4
-1 R 11
5 L 6
3 L 3
1

output:

0
0

result:

wrong output format Extra information in the output file