QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401645#7757. Palm IslandLspeed#WA 1ms3616kbC++143.2kb2024-04-29 06:46:352024-04-29 06:46:35

Judging History

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

  • [2024-04-29 06:46:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3616kb
  • [2024-04-29 06:46:35]
  • 提交

answer

#include <iostream>     // Input/output stream objects
#include <fstream>      // File stream objects
#include <sstream>      // String stream objects
#include <iomanip>      // Input/output manipulators
#include <string>       // String class and functions
#include <vector>       // Dynamic array
#include <list>         // Doubly linked list
#include <set>          // Set container
#include <map>          // Map container
#include <queue>        // Queue container
#include <stack>        // Stack container
#include <algorithm>    // Algorithms on sequences (e.g., sort, find)
#include <cmath>        // Mathematical functions
#include <ctime>        // Date and time functions
#include <cstdlib>      // General purpose functions (e.g., memory management)
#include <cstring>      // C-style string functions
#include <cctype>       // Character classification functions
#include <cassert>      // Assert function for debugging
#include <exception>    // Standard exceptions
#include <functional>   // Function objects
#include <iterator>     // Iterator classes
#include <limits>       // Numeric limits
#include <locale>       // Localization and internationalization
#include <numeric>      // Numeric operations (e.g., accumulate)
#include <random>       // Random number generators
#include <stdexcept>    // Standard exception classes
#include <typeinfo>     // Runtime type information
#include <utility>      // Utility components (e.g., std::pair)
#include <bitset>

using namespace std;

#define FOR(i, a, b) for(int i = a; i < (b); i++)
#define FORE(i, a, b) for(int i = a; i <= (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first 
#define y second
#define mp make_pair
#define PI 3.141592653
const double eps = 1e-9;

int T;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        vector<int> st(n+5), en(n+5), pos(n+5);
        FORE (i, 1, n) cin >> st[i];
        FORE (i, 1, n) {
            cin >> en[i];
            pos[en[i]] = i;
            en[i] = i;
        }
        FORE (i, 1, n) st[i] = pos[st[i]];

        // FORE (i, 1, n) cout << st[i] << " ";
        // cout << endl;
        // FORE (i, 1, n) cout << en[i] << " ";
        // cout << endl;

        vector<int> ans;    
        int temp = 0;
        while (true) {
            temp ++;
            bool chk = false;

            FORE (i, 1, n) chk |= (st[i] != en[i]);
            if (!chk) break;

            // cout << "START ";
            // FORE (i, 1, n) cout << st[i] << " ";
            // cout << endl;

            // cout << "ANS ";
            // for (int x: ans) cout << x;
            // cout << endl;

            for (int i = 1; i <= n; ) {
                if (i <= n-1 && st[i] > st[i+1]) {
                    ans.push_back(2);
                    ans.push_back(1);
                    swap(st[i], st[i+1]);
                    i += 2;
                }
                else {
                    ans.push_back(1);
                    i ++;
                }
            } 
        }

        for (int x: ans) cout << x;
        cout << endl;
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

input:

2
3
1 2 3
2 3 1
4
1 2 3 4
2 1 3 4

output:

211121
2111

result:

ok Correct. (2 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

200
3
3 1 2
2 3 1
4
2 4 1 3
2 1 4 3
4
1 4 2 3
2 1 3 4
5
4 3 2 1 5
2 4 5 3 1
5
2 1 5 4 3
5 2 4 1 3
4
4 3 1 2
1 2 4 3
3
1 2 3
3 1 2
4
1 4 2 3
2 1 4 3
4
1 3 2 4
1 4 3 2
3
3 2 1
1 3 2
3
2 3 1
1 3 2
4
1 4 3 2
3 1 2 4
3
1 2 3
1 3 2
3
3 2 1
2 3 1
5
5 1 3 2 4
2 4 5 1 3
4
4 3 1 2
1 4 3 2
4
1 3 4 2
2 4 3 1
3
...

output:

121211
1211
12112121
1212121211
1211121211
121121211211
121211
12112111
11211211
121211
211121211
12112121
121
211
11211121212121112111
12112111
2121121121211211
211121

212111212121211
1211212112112111
211112112111
212112112111
212112111121
212111211121211
211121
121211121111121
121112121112111
121...

result:

ok Correct. (200 test cases)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

200
5
5 1 3 4 2
5 3 2 4 1
5
5 1 2 4 3
3 5 4 1 2
5
1 4 5 3 2
2 5 4 3 1
5
1 5 4 3 2
4 5 2 3 1
5
2 3 4 5 1
5 4 3 2 1
5
1 5 2 4 3
5 3 1 2 4
5
1 2 4 3 5
4 2 3 5 1
5
3 2 1 4 5
4 2 3 1 5
5
3 1 2 5 4
2 4 1 3 5
5
5 3 1 4 2
2 5 4 1 3
5
5 4 3 1 2
2 5 4 1 3
5
3 4 5 2 1
3 5 1 4 2
5
4 5 1 3 2
4 2 3 1 5
5
1 3 4 5 ...

output:

121211121111121
1121112121112111211121111
2112112111212111212121111
21121121112121111121
21211121112121112111
211211121112111
21111121112121111121
212111211121111
21121121112121112111
12121112111212121211
1121111121112111211121111
1212111211
12121112111212111211
211211211121111

121111121112121
2121...

result:

ok Correct. (200 test cases)

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3612kb

input:

100
5
1 2 5 4 3
2 4 5 3 1
6
6 1 5 2 4 3
1 4 5 6 2 3
3
2 1 3
1 2 3
5
5 3 4 2 1
1 2 3 5 4
10
5 9 4 2 6 10 7 8 3 1
1 3 4 10 5 7 2 9 8 6
10
5 9 10 7 8 3 4 6 2 1
2 7 4 3 10 9 5 8 1 6
8
1 7 4 6 3 5 2 8
3 5 1 4 6 8 7 2
4
2 3 4 1
1 4 2 3
7
3 7 4 6 2 1 5
5 6 7 3 4 1 2
8
2 1 4 7 8 3 6 5
5 2 7 4 3 1 8 6
4
3 2 ...

output:

21211121111121111121
211211121111112111121111
211
2121112121212111211121111
121121121121211211211112112111112121121112121211211111212111111212111111212111111212111111212111111112111111112111111111
212121121112121211212121212111121212111111212111111212121111112121111112111111112111111111
121211211121...

result:

wrong answer On Case#5: The lenght of your output is 120(exceed n*n = 100). (test case 5)