Submission #1311256
Source Code Expand
import java.io.IOException; import java.io.InputStream; import java.util.NoSuchElementException; public class Main { private static FastScanner sc = new FastScanner(); public static void main(String[] args) { char[] ud = sc.next().toCharArray(); long ans = 0; for(int i=0; i<ud.length; i++) { if(ud[i] == 'U') { ans += (ud.length - i - 1) + (i * 2); } else { ans += (ud.length - i - 1) * 2 + i ; } } System.out.println(ans); } static class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;} public boolean hasNext() { skipUnprintable(); return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { return Long.parseLong(next()); } public int nextInt(){ return Integer.parseInt(next()); } } }
Submission Info
Submission Time | |
---|---|
Task | A - A+...+B Problem |
User | Shun_PI |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1935 Byte |
Status | WA |
Exec Time | 68 ms |
Memory | 21332 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | WA | 66 ms | 19284 KB |
02.txt | WA | 67 ms | 19156 KB |
03.txt | WA | 67 ms | 19156 KB |
04.txt | WA | 68 ms | 21076 KB |
05.txt | AC | 68 ms | 20948 KB |
06.txt | AC | 68 ms | 18772 KB |
07.txt | WA | 66 ms | 21204 KB |
08.txt | WA | 66 ms | 21332 KB |
s1.txt | WA | 68 ms | 20820 KB |
s2.txt | AC | 67 ms | 15828 KB |
s3.txt | AC | 67 ms | 20308 KB |
s4.txt | WA | 65 ms | 17620 KB |