QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#850476#8355. T3rqoi031#15 5ms1988kbC++201.4kb2025-01-10 09:14:392025-01-10 09:14:41

Judging History

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

  • [2025-01-10 09:14:41]
  • 评测
  • 测评结果:15
  • 用时:5ms
  • 内存:1988kb
  • [2025-01-10 09:14:39]
  • 提交

answer

#include<stdio.h>
#include<algorithm>
#include<numeric>
#include<vector>
constexpr int N{300};
enum direction {
    U,D,L,R
};
char ch[4]{'U','D','L','R'};
int cnt[4][N+5];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i!=4;i++) {
        for(int j=1;j<=n;j++) {
            scanf("%d",cnt[i]+j);
        }
    }
    if([&]()->bool {
        for(int i=1;i<=n;i++) {
            if(cnt[D][i]!=0||cnt[R][i]!=0) {
                return false;
            }
        }
        return true;
    }()) {
        static int perm[N+5]{},aux[N+5]{},tag[N+5][N+5]{};
        std::copy(cnt[U]+1,cnt[U]+n+1,aux+1);
        for(int i=1;i<=n;i++) {
            std::iota(perm+1,perm+n+1,1);
            std::sort(perm+1,perm+n+1,[&](const int &x,const int &y)->bool {
                return aux[x]<aux[y];
            });
            for(int j=1;j<=cnt[L][i];j++) {
                ++aux[perm[j]];
                tag[i][perm[j]]=1;
            }
        }
        if(*std::max_element(aux+1,aux+n+1)!=n) {
            return puts("NO"),0;
        }
        for(int i=1;i<=n;i++) {
            for(int j=1;j<=n;j++) {
                if(tag[i][j]) {
                    printf("L%d\n",i);
                }
                else {
                    printf("U%d\n",j);
                }
            }
        }
        return 0;
    }
    puts("NO");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1520kb

input:

1
0
1
0
0

output:

NO

result:

wrong answer Your program doesn't find a solution

Subtask #2:

score: 15
Accepted

Test #11:

score: 15
Accepted
time: 4ms
memory: 1928kb

input:

290
28 35 25 29 26 23 36 36 24 39 27 36 24 26 31 28 30 27 25 32 37 26 38 20 31 30 30 35 33 24 25 27 20 26 32 26 33 38 25 29 27 34 25 31 21 22 33 33 24 24 31 31 26 31 25 28 33 27 30 27 24 30 29 26 32 36 20 31 28 23 22 23 37 32 32 27 33 30 27 42 25 31 25 25 26 32 25 35 28 27 33 26 35 39 23 22 26 29 35...

output:

L1
L1
L1
L1
L1
L1
L1
U8
L1
U10
L1
U12
L1
L1
L1
L1
L1
L1
L1
L1
U21
L1
U23
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
U38
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
U73
L1
L1
L1
L1
L1
L1
U80
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
U94
L1
L1
L1
L...

result:

ok OK

Test #12:

score: 15
Accepted
time: 4ms
memory: 1884kb

input:

277
53 51 63 63 45 55 51 56 53 55 59 51 54 60 48 59 62 45 51 55 61 55 57 51 52 61 47 59 61 52 50 51 44 59 61 59 45 47 66 55 71 59 55 66 63 56 50 56 55 53 53 51 58 55 48 60 67 54 58 49 48 52 63 52 61 66 52 64 57 61 50 61 58 58 48 56 76 56 49 55 57 52 44 62 59 55 50 47 53 52 69 51 56 55 64 52 49 59 55...

output:

L1
L1
U3
U4
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
U17
L1
L1
L1
U21
L1
L1
L1
L1
U26
L1
L1
U29
L1
L1
L1
L1
L1
U35
L1
L1
L1
U39
L1
U41
L1
L1
U44
U45
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
U57
L1
L1
L1
L1
L1
U63
L1
U65
U66
L1
U68
L1
U70
L1
U72
L1
L1
L1
L1
U77
L1
L1
L1
L1
L1
L1
U84
L1
L1
L1
L1
L1
L1
U91
L1
L1
L1...

result:

ok OK

Test #13:

score: 15
Accepted
time: 5ms
memory: 1972kb

input:

282
100 80 83 92 99 86 81 73 90 97 79 88 78 90 93 75 80 95 88 75 73 86 84 76 86 80 89 87 84 81 78 84 75 86 76 81 85 101 69 88 80 86 86 97 83 83 71 94 82 98 79 79 82 84 96 83 90 82 69 82 90 80 85 89 99 76 94 87 85 78 74 93 69 85 87 75 87 95 77 77 86 71 88 73 91 88 72 86 85 78 88 82 82 96 90 79 79 82 ...

output:

U1
L1
L1
U4
U5
L1
L1
L1
U9
U10
L1
U12
L1
U14
U15
L1
L1
U18
U19
L1
L1
L1
L1
L1
L1
L1
U27
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
U38
L1
U40
L1
L1
L1
U44
L1
L1
L1
U48
L1
U50
L1
L1
L1
L1
U55
L1
U57
L1
L1
L1
U61
L1
L1
U64
U65
L1
U67
L1
L1
L1
L1
U72
L1
L1
U75
L1
L1
U78
L1
L1
L1
L1
U83
L1
U85
U86
L1
L1
L1
L1
U91
L1...

result:

ok OK

Test #14:

score: 15
Accepted
time: 4ms
memory: 1976kb

input:

287
98 119 107 123 117 117 121 115 127 128 115 133 111 117 110 96 91 113 110 110 114 105 114 109 98 108 120 129 113 103 99 119 104 123 100 111 117 118 125 126 124 123 114 105 121 108 128 107 124 126 118 116 114 125 119 103 111 119 129 120 121 109 113 108 109 122 119 119 116 119 113 122 124 117 126 1...

output:

L1
U2
L1
U4
U5
U6
U7
L1
U9
U10
L1
U12
L1
U14
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
U27
U28
L1
L1
L1
U32
L1
U34
L1
L1
U37
U38
U39
U40
U41
U42
L1
L1
U45
L1
U47
L1
U49
U50
U51
L1
L1
U54
U55
L1
L1
U58
U59
U60
U61
L1
L1
L1
L1
U66
U67
U68
L1
U70
L1
U72
U73
L1
U75
U76
U77
U78
U79
L1
L1
L1
L1
L1
U85
U86
L1
L1...

result:

ok OK

Test #15:

score: 15
Accepted
time: 4ms
memory: 1932kb

input:

265
144 139 128 130 134 135 140 122 129 143 129 132 132 135 120 135 146 138 129 132 111 123 154 138 128 124 125 135 134 141 130 127 146 123 131 133 122 142 140 146 140 141 128 119 133 134 137 148 123 134 142 127 124 137 130 132 136 128 142 126 134 126 138 137 133 141 119 137 146 137 136 126 141 127 ...

output:

U1
U2
L1
L1
U5
U6
U7
L1
L1
U10
L1
L1
L1
U14
L1
U16
U17
U18
L1
L1
L1
L1
U23
U24
L1
L1
L1
U28
U29
U30
L1
L1
U33
L1
L1
L1
L1
U38
U39
U40
U41
U42
L1
L1
L1
U46
U47
U48
L1
U50
U51
L1
L1
U54
L1
L1
U57
L1
U59
L1
U61
L1
U63
U64
L1
U66
L1
U68
U69
U70
U71
L1
U73
L1
L1
U76
L1
U78
L1
L1
L1
L1
U83
U84
U85
L1
U87
...

result:

ok OK

Test #16:

score: 15
Accepted
time: 1ms
memory: 1828kb

input:

286
235 245 221 241 222 248 226 244 228 207 234 229 241 261 209 231 222 203 225 230 256 224 236 243 222 246 235 243 247 234 241 255 232 234 211 258 249 238 252 237 240 221 244 223 212 240 259 261 235 264 238 205 224 223 238 222 199 225 222 217 236 220 212 204 230 253 221 214 195 216 219 239 220 233 ...

output:

NO

result:

ok OK

Test #17:

score: 15
Accepted
time: 4ms
memory: 1940kb

input:

268
187 183 183 184 179 189 177 173 176 186 183 182 187 175 185 218 176 191 195 183 182 197 182 195 195 183 185 193 205 182 192 179 183 176 190 185 195 182 189 189 196 184 194 184 199 189 190 190 191 201 197 196 190 186 186 197 188 190 188 171 191 186 181 188 170 188 176 188 190 190 187 181 190 187 ...

output:

U1
L1
U3
U4
L1
U6
L1
L1
L1
U10
L1
L1
U13
L1
U15
U16
L1
U18
U19
U20
L1
U22
L1
U24
U25
L1
U27
U28
U29
L1
U31
L1
L1
L1
U35
U36
U37
L1
U39
U40
U41
U42
U43
U44
U45
U46
U47
U48
U49
U50
U51
U52
U53
U54
U55
U56
U57
U58
U59
L1
U61
U62
L1
U64
L1
U66
L1
U68
U69
U70
U71
L1
U73
U74
U75
U76
U77
L1
U79
U80
L1
U82
...

result:

ok OK

Test #18:

score: 15
Accepted
time: 4ms
memory: 1908kb

input:

261
204 204 215 204 209 212 197 219 216 205 210 208 216 205 207 203 217 203 209 208 211 207 210 213 200 206 213 208 214 205 200 220 206 210 213 209 206 207 207 201 212 213 212 206 225 210 196 221 205 217 202 206 212 205 196 218 205 209 194 206 199 204 219 204 222 208 208 210 195 208 215 211 201 206 ...

output:

U1
U2
U3
U4
U5
U6
L1
U8
U9
U10
U11
U12
U13
U14
U15
U16
U17
U18
U19
U20
U21
U22
U23
U24
L1
U26
U27
U28
U29
U30
L1
U32
U33
U34
U35
U36
U37
U38
U39
L1
U41
U42
U43
U44
U45
U46
L1
U48
U49
U50
L1
U52
U53
U54
L1
U56
U57
U58
L1
U60
L1
U62
U63
U64
U65
U66
U67
U68
L1
U70
U71
U72
L1
U74
L1
U76
U77
U78
U79
U80
...

result:

ok OK

Test #19:

score: 15
Accepted
time: 4ms
memory: 1988kb

input:

281
251 252 254 244 260 254 254 245 251 258 258 253 256 263 249 256 252 253 247 253 250 249 243 248 264 246 246 264 242 256 245 258 257 251 252 247 252 259 251 253 252 246 255 261 255 249 251 250 255 255 257 246 251 254 250 255 256 258 256 257 254 254 252 254 263 258 262 253 255 250 250 254 245 264 ...

output:

U1
U2
U3
L1
U5
U6
U7
L1
U9
U10
U11
U12
U13
U14
U15
U16
U17
U18
U19
U20
U21
U22
L1
U24
U25
L1
U27
U28
L1
U30
L1
U32
U33
U34
U35
U36
U37
U38
U39
U40
U41
U42
U43
U44
U45
U46
U47
U48
U49
U50
U51
U52
U53
U54
U55
U56
U57
U58
U59
U60
U61
U62
U63
U64
U65
U66
U67
U68
U69
U70
U71
U72
L1
U74
U75
U76
U77
U78
U7...

result:

ok OK

Test #20:

score: 15
Accepted
time: 3ms
memory: 1840kb

input:

253
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
L1
...

result:

ok OK

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 1484kb

input:

289
30 29 31 35 25 34 26 28 25 25 44 26 33 30 27 30 33 37 26 27 43 28 28 40 31 36 21 26 35 28 31 29 41 25 30 25 35 28 38 24 26 26 24 24 25 27 18 44 31 24 37 28 26 31 27 32 29 24 24 32 20 35 26 39 30 28 33 30 27 28 37 35 29 22 27 27 31 30 25 31 31 22 30 34 33 31 30 29 41 26 38 36 28 28 21 22 31 34 32...

output:

NO

result:

wrong answer Your program doesn't find a solution

Subtask #4:

score: 0
Wrong Answer

Test #31:

score: 25
Accepted
time: 0ms
memory: 1584kb

input:

1
1
0
0
0

output:

U1

result:

ok OK

Test #32:

score: 0
Wrong Answer
time: 0ms
memory: 1516kb

input:

2
0 1
0 1
0 0
1 1

output:

NO

result:

wrong answer Your program doesn't find a solution

Subtask #5:

score: 0
Wrong Answer

Test #77:

score: 0
Wrong Answer
time: 0ms
memory: 1344kb

input:

299
72 66 62 73 80 85 70 93 79 88 77 72 67 70 73 84 77 62 80 77 88 63 69 76 73 91 64 76 75 65 74 71 71 68 81 80 74 77 69 75 73 87 90 82 86 79 76 83 69 72 73 73 75 78 76 80 66 76 67 75 72 71 77 63 80 68 82 63 74 67 74 72 73 76 71 72 66 78 74 65 69 80 76 71 72 74 77 70 85 60 65 89 66 64 77 63 78 82 80...

output:

NO

result:

wrong answer Your program doesn't find a solution